RE: [PHP] Question: Checkboxes & Variables
| From: | Sri dot Purnomo at BAKERNET dot com | Date: | Mon, 10 Jul 2000 05:03:57 +0000 |
| Subject: | RE: [PHP] Question: Checkboxes & Variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-5682@lists.php.net to get a copy of this message | ||
Hello,
IMHO PHP can pass a checkbox as an array variable.
So the html codes below will pass an array of items to PHP that contains only
checked values.
<form action='...'>
<table>
<tr><td><input type='checkbox' name='items[]'
value='ball'>ball</tr>
<tr><td><input type='checkbox' name='items[]'
value='shoe'>shoe</tr>
<tr><td><input type='checkbox' name='items[]'
value='hat'>hat</tr>
<tr><td><input type='checkbox' name='items[]'
value='hammer'>hammer</tr>
....
....
</table>
<input type='submit' value='send'>
</form>
I have no problem using this method to process more than 20 checkboxes.
Regards,
Purnomo
-----Original Message-----
From: Daniel Murillo [mailto:damurillo@amherst.edu]
Sent: Monday, July 10, 2000 5:07 AM
To: php-general@lists.php.net
Subject: [PHP] Question: Checkboxes & Variables
I am trying to create a form with checkboxes where individuals can select as
many checkboxes as they wish and get results depending on what they checked.
(I.E., If a person selects a checkbox marked "ball" and a checkbox marked
"spike" then the next page will display results that match either "ball" or
"spike".) The problem is that I cannot give each individual checkbox its
own specific name because then I would have to create a loop to see which
variables have been given a value, which would be too time intensive since
the number of checkboxes available would be around 20. Now, since every
checkbox has the same name, with each clicking of a new checkbox it
overwrites the previous value that was assigned to that variable (duh). I am
wondering if there is a way to append the checkbox values to the variable or
if there is possibly some easier way to do this that I am missing.
thanks,
Daniel Murillo
damurillo@amherst.edu
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net