[thelist] Finding all checkboxes or radios w same name, without document.all

Dave Merrill dmerrill at usa.net
Mon Feb 7 18:38:19 CST 2005


Suppose I want to iterate through all checkboxes on a form that have some
specified name. The proprietary old-style way to do that would be:

for(var i = 0; i < document.all[cbName].length; i++) {
	//do something with document.all[cbName][i]
}

Is there any multi-browser-friendly equivalent that doesn't use
document.all? I could iterate through document.myForm.elements, checking all
of them for matches on the name, but that seems ugly and inefficient.

Any other choices? getElementsByName would be ideal, returning an array of
all matches, but as far as I know, it doesn't exist.

Thanks in advance,

Dave Merrill




More information about the thelist mailing list