El Jue 24 Oct 2002 12:30, escribiste:
Hi, I still learning JavaScript, so take this with the proper caution.
"checked" is a boolean value (true or false), so you should use an "if"
statment; something like this:
for ( i = 0; i < document.forms[0].elements['somename[]'].length; i++ )
{
if ( document.forms[0].elements['somename[]'][i].checked == true)
alert ( document.forms[0].elements['somename[]'][i]);
}
Mario.
> Hi guys and gals,
>
> I'm trying to validate a checkbox element in a form. Due to using php
> to process this form, the checkbox element must have a name ending in
> square brackets...
>
> <input type="checkbox" value="somevalue" name="somename[]" />
>
> The problem I'm having is trying to loop thru this element to see if at
> least one of the boxes are checked....
>
> for ( i = 0; i < document.forms[0].elements['somename[]'].length; i++ )
> {
> alert ( document.forms[0].elements['somename[]'][i].checked );
> }
>
> This gives me an error. What's the proper syntax for this?
>
> ____ � The WDVL Discussion List from WDVL.COM � ____
> To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED]
> Send Your Posts To: [EMAIL PROTECTED]
> To change subscription settings to the wdvltalk digest version:
> http://wdvl.internet.com/WDVL/Forum/#sub
>
> ________________ http://www.wdvl.com _______________________
>
> You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to %%email.unsub%%
>
>
____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED]
Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]