On 28 August 2008 00:04, tedd advised:

> At 12:07 AM +0200 8/28/08, Maciek Sokolewicz wrote:

>> <input type="check" name="my_checkboxes[1]" value="1" /> 1<br />
>> <input type="check" name="my_checkboxes[2]" value="1" /> 1<br />
>> <input type="check" name="my_checkboxes[3]" value="1" /> 1<br />
>> <input type="check" name="my_checkboxes[4]" value="1" /> 1<br />
>> 
>> $my_checked_checkboxes = $_REQUEST['my_checkboxes']; // whichever
>> you wish, $_GET or $_POST, I don't care right now; you choose.
> 
> Yeah, I remember that -- but a bit different.
> 
> Don't use indexes, but rather just my_checkboxes[]
> 
> and on the php side
> 
> $my_checked_checkboxes = $_REQUEST['my_checkboxes'];
> 
> The array $my_checked_checkboxes equals the $_REQUEST$_/$_POST/$_GET
> array -- all the indexes will match (i.e., $my_checked_checkboxes[3]
is
> the same as $_POST[3]). 
> 
> The only problem I have with that method is that the [] becomes
> confusing with dealing with javascript that can also handles the form.
> 
> One of the ways to get around this is to:
> 
> <input type="checkbox" name="my_checkboxes[]"
> id="my_checkbox_1" value="1" >
> 
> That way php will use "name" and javascript will use "id".

Why???

  <form name="my_form" ... >
     <input type="checkbox" name="my_checkboxes[]" ... >
  </form>

  <script language="Javascript">
  checkboxes = document.my_form["my_checkboxes[]"];
  </script>

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to