Multiple check boxs
Moderator: General Moderators
-
petethepirate
- Forum Newbie
- Posts: 10
- Joined: Sat Oct 04, 2008 5:33 pm
Multiple check boxs
I cant figure this one out. I need mutiple check boxes (form submit) for each item, not just one check box. For example, lets say I list out fruit items at a grocery store. For each item I have a check box for BUY, INSPECT, and SMELL. I can check one, two, all three, or none at all. Anyone know how to do this? Thanks.
Re: Multiple check boxs
Unless I don't understand what you want to do, just give each checkbox a different name. What are you doing with the data?petethepirate wrote:I cant figure this one out. I need mutiple check boxes (form submit) for each item, not just one check box. For example, lets say I list out fruit items at a grocery store. For each item I have a check box for BUY, INSPECT, and SMELL. I can check one, two, all three, or none at all. Anyone know how to do this? Thanks.
-
petethepirate
- Forum Newbie
- Posts: 10
- Joined: Sat Oct 04, 2008 5:33 pm
Re: Multiple check boxs
I am giving them different names. Lets say someone clicks two different check boxs on line 2, all it returns is ON for line 2. Im trying to get 3 different values from each line.
Re: Multiple check boxs
I can't visualize what you mean. Show us the code for your Form (please enclose php code in bracketed php tags for readability--that is, use the Code button on the message input screen, and change the "text" to "php" if it's php code).petethepirate wrote:I am giving them different names. Lets say someone clicks two different check boxs on line 2, all it returns is ON for line 2. Im trying to get 3 different values from each line.
Re: Multiple check boxs
So its like
Apple: []Buy
[]Inspect
[]Smell
Pear: []Buy
[]Inspect
[]Smell
Lets say Apple has buy and smell selected, an array called apple now contains Buy and Smell. When you post you can do whatever with the array eg.
Apple: []Buy
[]Inspect
[]Smell
Pear: []Buy
[]Inspect
[]Smell
Code: Select all
<?php
echo "Apple: <input type='checkbox' name='apple[]' value='Buy'>Buy<br>
<input type='checkbox' name='apple[]' value='Inspect'>Inspect<br>
<input type='checkbox' name='apple[]' value='Smell'>Smell<br><br>";
echo "Pear: <input type='checkbox' name='pear[]' value='Buy'>Buy<br>
<input type='checkbox' name='pear[]' value='Inspect'>Inspect<br>
<input type='checkbox' name='pear[]' value='Smell'>Smell<br><br>";
?>Code: Select all
<?php
$applestuff = implode(', ', $_POST['apple']); //Converts an array into a single string
echo $applestuff; //Output: Buy, Smell
?>-
petethepirate
- Forum Newbie
- Posts: 10
- Joined: Sat Oct 04, 2008 5:33 pm
Re: Multiple check boxs
Thanks!