note 33955 added to language.types.array

From: Date: Fri, 11 Jul 2003 21:59:52 +0000
Subject: note 33955 added to language.types.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-51940@lists.php.net to get a copy of this message
I was having trouble getting javascript arrays and php arrays to work together with a Check All checkboxe. Here is a simple solution. Clicking the 'Check All' checkbox will check all checkboxes on the form. <script language="JavaScript"> function chkAll(frm, arr, mark) { for (i = 0; i <= frm.elements.length; i++) { try{ if(frm.elements[i].name == arr) { frm.elements[i].checked = mark; } } catch(er) {} } } </script> <form name='foo'> <input type="checkbox" name="ca" value="1" onClick="chkAll(this.form, 'formVar[chkValue][]', this.checked)"> <?php for($i = 0; $i < 5; $i++){ echo("<input type='checkbox' name='formVar[chkValue][]' value='$i'>"); } ?> </form> Dean M. ---- Manual Page -- http://www.php.net/manual/en/language.types.array.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33955 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33955&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33955&report=yes

« previous php.notes (#51940) next »