Re: how to select all checkbox?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: how to select all checkbox?

From: RobG <rgqld@iinet.net.auau>
Date: Mon Aug 01 2005 - 08:45:21 CEST

_andrea.l wrote:
> I get the opportunity to thank you and all the people how had answer or just
> read all my questions (this and all in the past).
>
> I have a question:
> I don't understand well this line:
>
>> if ( 'input' == x.nodeName.toLowerCase() &&
>
> what is userfull for?

That test is within a while loop, it looks to see if the current node is
an input element and if it is, it then checks to see if it's a checkbox.

If either of the above are not true, the loop goes to the next element.

If both the above tests are true, the checkbox is set to checked or not
depending on whether the 'tick' parameter is true or false respectively.

It is important to do a sequence of tests as simply assuming that the
node is a checkbox and attempting set its 'checked' property may cause
an error. By testing in sequence with an AND ( && ) test, the 'if'
statement should pass or fail gracefully for any element it may come across.

I should note that the above is a bit of 'belt and braces' approach.
You should be able to set a 'checked' attribute on any form element
(even those that have no 'checked' attribute defined in the HTML
specification) without generating an error, but I can't guarantee that
will occur in every case for all browsers.

>
> Thank you in advance,
> Andrea.
>
>

-- 
Rob
Received on Tue Oct 18 03:04:00 2005