note 32620 added to language.types.array
| From: | wayne at php247 dot com | Date: | Tue, 03 Jun 2003 09:46:22 +0000 |
| Subject: | note 32620 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49603@lists.php.net to get a copy of this message | ||
For those of you who are having trouble getting the PHP arrays working with JavaScript to do a
"check all", or "uncheck all" facility for checkboxes, use this code:
function checkAll()
{
boxlist = document.forms.MyFormName.elements["MyArray[]"];
for (i = 0; i < boxlist.length; i++)
boxlist[i].checked = true;
}
function uncheckAll()
{
boxlist = document.forms.MyFormName.elements["MyArray[]"];
for (i = 0; i < boxlist.length; i++)
boxlist[i].checked = false;
}
Here's an example of how to use the functions:
<INPUT TYPE="button" onClick="checkAll()" VALUE="Check All">
<INPUT TYPE="button" onClick="uncheckAll()" VALUE="Uncheck All">
This will check, or uncheck, all of the checkboxes identified by the variable name MyArray[] on a
form named MyFormName. Replace MyArray[] and MyFormName with whatever your own form and variable
names are.
Enjoy !
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32620
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32620&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32620&report=yes