RE: [PHP] checkbox arrays and validation
| From: | Ford, Mike | Date: | Tue, 05 Oct 2004 13:09:32 +0000 |
| Subject: | RE: [PHP] checkbox arrays and validation | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-198660@lists.php.net to get a copy of this message | ||
On 05 October 2004 13:55, Angelo Zanetti wrote:
> Hi Marek,
>
> I try to access the array like this:
>
> document.frmft.elements["chkmodels[]"];
>
> but doesnt work. I also tried this:
>
> models = document.forms['frmft'].elements["chkmodels[]"];
>
> is there not a problem with the elements part?
So long as your form goes something like:
<form name="frmft" ....>
<input type="checkbox" name="chkmodels[]" value="1">Value
1<br>
<input type="checkbox" name="chkmodels[]" value="2">Value
2<br>
<input type="checkbox" name="chkmodels[]" value="3">Value
3<br>
...
</form>
you can refer to the checkboxes simply as
document.frmft["chkmodels[]"]
This is the way I've always done it, and it's always worked a treat.
Of course, in this situation this will give you an array of checkbox objects which you then have to
index into, but that's a whole other story.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211