Jump to content

Recommended Posts

Hi all,

 

I have a form which creates checkboxes dynamically.

 

This is the code for the checkbox generation

<div class="column">
        <?php
$dir = "pdfs/";
$dh = opendir($dir);
echo $file;
$tindex="-2";
while (($file = readdir($dh)) !== false) {
$tindex++;
if($file=='.') continue;
  if($file=='..') continue;
echo "<input id=\"id_$file\" name=\"name_$file\" type=\"checkbox\" class=\"field checkbox\" value=\"$file\" tabindex=\"$tindex\" checked=\"checked\" />
          <label class=\"choice\" for=\"Field101\">$file</label>
          ";

}

closedir($dh);

?>
          
        </div>

 

So what i need to do now is somehow on the page (processfiles.php - defined in the form action)that the gets the post values is something like this

i used $file in each of the parameters - but thats not really necessary I just need the $file as the value of the checkbox that gets posted.

 

For each checkbox value start processing this code then when done bounce back to the form page with with a url value  processing=done.

 

Does that make any sort of sense!! :D

 

 

You must be doing it wrong. Example

 

<input name="items[]" type="checkbox" value="1" />
<input name="items[]" type="checkbox" value="2" />
<input name="items[]" type="checkbox" value="3" />

// Processing part

foreach($_POST['items'] as $item) {
  // do something with the selected item
}

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.