Normally you shouldn't give more than one element on a page the same id. The "getElementById" method will only return the first element with that id. You can do it, but its considered bad form.
But sometimes you may need to do it as in the case where someone else has written the HTML and you are not allowed to alter it. Here's how:
//get an array containing all references with a like id
function multiId(id){
var x, i, len, h;
h = [];
do{
x = document.getElementById(id);
if(x !== null){
h.push(x);
x.id = undefined;
}
}while(x !== null);
//now put the id's back
len = h.length;
for(i = 0; i < len; i++){
h[i].id = id;
}
return h;
}
//at this point you can use the return value (an array) to loop through the elements
var z = multiId('myId');
for(var i =0; i < z.length; i++){
z[i].disabled = true;
}