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.

 

 

 

 

 

 

 

 

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.