★ wanayoo — archive 1999 http://www.devshed.com/Talk/Forums/Forum5/HTML/000409.htmlNouvelle recherche | Portail wanayoo
DevShed Menu
* DevShed Home
* Developer News
* DevShed Brain Dump




UBBFriend: Email This Page to Someone!
  DevShed Discussion Forums
  PHP
  processing checkboxes

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   processing checkboxes
Carolyn
Junior Member
posted January 03, 2000 10:52 PM     Click Here to See the Profile for Carolyn   Click Here to Email Carolyn     Edit/Delete Message Reply w/Quote
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     Click Here to See the Profile for PAV   Click Here to Email PAV     Edit/Delete Message Reply w/Quote
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     Click Here to See the Profile for acmearts     Edit/Delete Message Reply w/Quote
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     Click Here to See the Profile for Dist   Click Here to Email Dist     Edit/Delete Message Reply w/Quote
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);
}
---

All times are MST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | DevShed.com

Copyright © 1997-2000 ngenuity. All rights reserved.

Powered by: Ultimate Bulletin Board, Version 5.41a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.