|
Author
|
Topic: processing checkboxes
|
Carolyn Junior Member
|
posted January 03, 2000 10:52 PM
If I choose more than one item in a checkbox list, PHP feeds back only the last choice. Why?For example, I select 'dogs', 'cats' and 'mice', it sets the variable to 'mice' only. |
PAV Member
|
posted January 04, 2000 05:28 AM
You can put the results of all checked checkboxes in an array, let's say pets.<input type="checkbox" name=pets[] value="dog">Dog <input type="checkbox" name=pets[] value="cat">Cat etc. Only when a box is checked, PHP puts the value in the array pets[], starting with index 0. Then you can read out all the checked values from the array. Peter |
acmearts Junior Member
|
posted April 11, 2000 03:17 PM
I'm trying to get an array working with a dynamic multiple select box. I have put the rusults in an array but am unsure of how to explode the array on my action page. If in the example below, someone selected both dog and cat, how could I send two emails to them. One about dogs and one about cats. |
Dist Member
|
posted April 12, 2000 06:20 PM
Here's something for both questions: --- ?> <form> Select:<br> <select name="checks[]" size=5 multiple> <option value="cats">Cats <option value="dogs">Dogs </select><br>Checkboxes:<br> <input type="checkbox" name="checks[]" value="dogs2">Dogs<br> <input type="checkbox" name="checks[]" value="cats2">Cats<br> </form> <? function send_mail_about($subject) { print $subject . "<br>\n"; } while(list($dummy,$value)=@each($checks)) { print send_mail_about($value); } ---
|