Jump to content

form add field question


jazzman

Recommended Posts

initially i would do it like this.

 

1. pass a hidden field that contains the current total of form fields.

2. when the button is pressed, post the hidden field and add 1.

3. run a while loop to display the results and decrease the hidden field by 1 until it reaches zero.

 

4. don't forget to post and echo the current form information so the user doesn't have to re-input.

 

something like this which can probably be simplified, but to break it down I'll go through it.

 

<?
//get field
$totalfields = $_POST['hiddenfield'];
//add one
$add1 = $totalfields + 1;
//run while loop

while($add1 > 0){

       echo 'the form field data would go here. do not forget to echo the contents from the post.';
       $add1 = $add1 - 1 ;//subtract 1 from the total until it reaches zero

}
//echo the hidden field + 1 to get next time.
$hiddentotal = $totalfields + 1;
echo '<input name="totalfields" type="hidden" value="' . $hiddentotal . '">';
?>

 

this should keep you from having to use JavaScript, but it will refresh the page.

 

 

 

 

 

 

 

 

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.