Jump to content

Dynamic Checkbox


gobbles

Recommended Posts

Hey All,

 

I got a bit of a problem thats giving me a major headache.

 

I have a form which generates checkboxes from a database, so there isnt a set number of them ... they are generated by the following:

 

while ($listing_row = mysql_fetch_array($listing_results)) {
        extract($listing_row);
        echo "<input type=\"checkbox\" name=\"checkbox\" value=\"".$description."\" id=\"list".$id."\" ><label for=\"list".$id."\">  " .$description . "</label><font color=\"#FF0000\">  -  ".$date_uploaded."</font><br />\r";
      } 

 

I want the next script to take each of the checked boxes and assign them to a variable so that i can recall them at a later stage.

 

For example ... if there was 150 checkboxes and only 2 were checked, then $checked1 would equal the description of the first checked box, $checked2 would equal the description of the second checked box, and so on.

 

Cheers

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

U already are doing that

$descriprion is returned if the checkbox is checked.

if checkbox is left unchecked, nothing is returned

 

checkboxes, only return values when they are checked.

 

so if u have 150 checkboxes, and 2 get checked

$_POST['checkbox'] wud return an array of 2 items (not 150)

with the $description of those 2 checked as a value

 

Link to comment
https://forums.phpfreaks.com/topic/90930-dynamic-checkbox/#findComment-466129
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.