Jump to content

checkbox groups


123guy

Recommended Posts

so I am forming some checkboxes in a php loop ( i am not showing the loop, but it is in a loop).  I need to be able to have multiple check box rows with multiple values.  I am doing a customer tracking system.  I need each check box to hold the Customer First, Last, and Memberid.  How can I do this using php?  I would prefer not to have to loop through an array, so if there is a way not to do that, it would be great!

 

 <input type="radio" name="CheckboxGroup" value="yes" id="CheckboxGroup1_0<?php echo $id; ?>"><input name="first" type="hidden" value="<?php echo $first; ?>"><input name="last" type="hidden" value="<?php echo $last; ?>"><input name="member" type="hidden" value="<?php echo $id; ?>">

 

 

Link to comment
https://forums.phpfreaks.com/topic/275193-checkbox-groups/
Share on other sites

If you already have the data in a database, which it appears you do, since you are outputting those values to the page, then just assign the id to the checkbox and then on the next page, pull those values from the database for the checkboxes that are checked.

 

So say you have multiple groups:

<input type="checkbox" name="response[]" value="<?php echo $id;?>"> Option 1
<br />
// Next loop
<input type="checkbox" name="response[]" value="<?php echo $id;?>"> Option 2

 

Then you can loop through the values in PHP.

foreach ($_POST['response'] as $theID) {

}
Link to comment
https://forums.phpfreaks.com/topic/275193-checkbox-groups/#findComment-1416328
Share on other sites

Yes, but you'll need to use similar radio names to make the select functionally work as they should

 

<input type="radio" name="radiobutton[0]" value="a"><br>
<input type="radio" name="radiobutton[0]" value="b"><br>
<input type="radio" name="radiobutton[1]" value="a"><br>
<input type="radio" name="radiobutton[1]" value="b"><br>
Link to comment
https://forums.phpfreaks.com/topic/275193-checkbox-groups/#findComment-1416334
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.