[Javascript] A better way to do this

tedd tedd at sperling.com
Thu May 1 08:05:26 CDT 2008


At 2:54 PM -0400 4/29/08, Claude Schneegans wrote:
>  >>There has to be a better way to do this:
>
>Try this (not checked):
>function checkAll( form )
>     {
>     for (var i = 1; i<= 5; i++)form['a'+i].checked = form.checkall.checked
>     }
>

Claude:

That was spot-on and worked.

What I found interesting was how you went from this:

    form.a1.checked

to this:

    form['a'+i].checked

which basically meant that:

    form.a1.checked = form['a1'].checked

That's neat to know/realize -- thanks!

tedd

-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the Javascript mailing list