doforumda Posted October 24, 2009 Share Posted October 24, 2009 hi i want to make a form. the form will have three text fields and with two buttons. what i want with this form is when the user enters the first three fields and if he wants to add more then he will click on add more button and on the same page three more fields will appear below the first three fields. the user will then enter these three fields then if he wants to add more then he will click on add more button. so three more fields will appear below the first six fields. user will enter these fields. he will be allowed to enter upto eight or less than eight times. once he finishes with this then he will click the second button to insert this data into db. i create the following form but it only works just for two times. how can i achieve this? my code is here <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> </head> <body> <form name="form1" method="post" action="cvEducation.php"> <label>Degree: <input type="text" name="degree1" id="degree1"> </label> <p> <label>CGPA/Grade: <input type="text" name="cgpa1" id="cgpa1"> </label> </p> <p> <label>Institute: <input type="text" name="institute1" id="institute1"> </label> </p> <p> <label> <?php if(!isset($_POST['return'])) { ?> <input type="submit" name="return" id="return" value="Save And Add Another"> <?php } ?> </label> <?php if(isset($_POST['return'])) { ?> <label>Degree: <input type="text" name="degree2" id="degree2"> </label> <p> <label>CGPA/Grade: <input type="text" name="cgpa2" id="cgpa2"> </label> </p> <p> <label>Institute: <input type="text" name="institute2" id="institute2"> </label> </p> <p> <label> <input type="submit" name="return" id="return" value="Add More"> </label> </p> <?php } ?> </p> </form> </body> </html> in this form i provide only one button but it will be two once this problem is solved. Link to comment https://forums.phpfreaks.com/topic/178827-need-help-in-php-forms/ Share on other sites More sharing options...
severndigital Posted October 24, 2009 Share Posted October 24, 2009 hmmmm ... this should maybe be moved to javascript or ajax forum. it will look much better if done using one of those two technologies, and you don't have to worry about the form being reset each time the page is loaded again. This one is a bit more complicated that a few posts. do a google search for Dynamic Form Fields, there are a ton of tutorials on this out with code you can just swipe and start using. I just did the search and the top one should get you what you need. Link to comment https://forums.phpfreaks.com/topic/178827-need-help-in-php-forms/#findComment-943409 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.