Click to See Complete Forum and Search --> : Loop through control with same name


Webskater
10-03-2003, 09:23 AM
I have a page that dynamically generates a number of rows each eith a checkbox in them called "Assign" - all within a form.

Can anyone tell me the syntax please to loop through the form element "Assign" (could be 1, might be 20) checking whether each instance of "Assign" is checked.

Thanks for any help.

Khalid Ali
10-03-2003, 09:44 AM
following function should do what you are after

function Process(){
var frm = document.getElementById("form1");
var len = frm.Assign.length;
var assign = frm.Assign;
if(len!=null){
alert("t1 is an array")
for(var n=0;n<len;n++){
alert("assign has value = "+assign[n]+" at index = "+n);
}
}else{
alert("t1 is not an array\nvalue in assign = "+assign.value)
}
}

Webskater
10-03-2003, 09:51 AM
Thanks Khalid.

Khalid Ali
10-03-2003, 09:53 AM
Hey ,,you are welcome..:D