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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.