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

Joe Ngo chilijoe at gmail.com
Mon Feb 7 19:13:10 CST 2005


Use DOM method getElementsByName(). This is a W3C standard and I
believe supported by most modern browsers.


On Mon, 7 Feb 2005 19:38:19 -0500, Dave Merrill <dmerrill at usa.net> wrote:
> 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
> 
> --
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
> 


-- 
Take back the web!
http://www.spreadfirefox.com


More information about the thelist mailing list