Jump to content

[SOLVED] Dynamic Form posting values for processing


nostrodamned

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
}

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.