|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi Guys,
I'm trying to validate my form and loop thorugh each checkbox to see if it has been checked. My html is below, Im trying to get the length of the checkbox array by using: alert(document.form.transport.length); However, it keeps saying it has no properties, can anyone please ? Thankyou <ffform name="form" action="#" method="post" onSubmit="return CheckFieldBlank()"> <input id="Bycycle" type="checkbox" name="transport" value="Bycycle" /> <input id="Motorscooter" type="checkbox" name="transport" value="Motorscooter" /> <input id="Motorbike" type="checkbox" name="transport" value="Motorbike" /> <input id="Car" type="checkbox" name="transport" value="Car" /> </form> |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Is this a typo?
<ffform name="form" -- Murray --- ICQ 71997575 Adobe Community Expert (If you *MUST* email me, don't LAUGH when you do so!) ================== http://www.projectseven.com/go - DW FAQs, Tutorials & Resources http://www.dwfaq.com - DW FAQs, Tutorials & Resources ================== "Mattastic" <webforumsuser@macromedia.com> wrote in message news:fuq21c$7jn$1@forums.macromedia.com... > Hi Guys, > > I'm trying to validate my form and loop thorugh each checkbox to see if it > has > been checked. My html is below, Im trying to get the length of the > checkbox > array by using: > > alert(document.form.transport.length); > > However, it keeps saying it has no properties, can anyone please ? > > Thankyou > > > > <ffform name="form" action="#" method="post" onSubmit="return > CheckFieldBlank()"> > <input id="Bycycle" type="checkbox" name="transport" > value="Bycycle" /> > <input id="Motorscooter" type="checkbox" name="transport" > value="Motorscooter" /> > <input id="Motorbike" type="checkbox" name="transport" > value="Motorbike" /> > <input id="Car" type="checkbox" name="transport" value="Car" /> > </form> > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Not in my code, I quickly typed up this post.
Thanks |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Mattastic wrote:
> Hi Guys, > > alert(document.form.transport.length); > > However, it keeps saying it has no properties, can anyone please ? > > Thankyou > > > > <ffform name="form" action="#" method="post" onSubmit="return > CheckFieldBlank()"> > "form" is a reserved word in js, I recommend you not use it. <body> <script> function CheckFieldBlank(form){ var a=form.transport.length,b=[]; alert(a); while(a--){ if(form.transport[a].checked)b.push(form.transport[a].value) } if(b.length) { alert("These checked:\n"+b.join("\n"));return true; } alert("none checked");return false; } </script> <form name="f" action="#" method="post" onsubmit="return CheckFieldBlank(this)"> <input id="Bycycle" type="checkbox" name="transport" value="Bycycle"> <input id="Motorscooter" type="checkbox" name="transport" value="Motorscooter"> <input id="Motorbike" type="checkbox" name="transport" value="Motorbike"> <input id="Car" type="checkbox" name="transport" value="Car"> <input name="smit" type="submit" value="go"> </form> </body> Mick |
|
![]() |
| Outils de la discussion | |
|
|