MDanz Posted July 27, 2010 Share Posted July 27, 2010 i have a form that i'd like to duplicate on the press of a button? echo "<form enctype='multipart/form-data' action='rapidinsert.php' method='post' name='changer'> <br /><br /> <font color='#D99C29' face='Arial' size='3px'>Add Noun </font><input type='text' name='noun' value='' size='30' /> <input type='submit' value='Submit' style='font-size:10px' /> <input type='submit' value='Add form' style='font-size:10px' /> </form>"; How do i duplicate this form every time i press Add form button? So it lists multiple forms. Quote Link to comment Share on other sites More sharing options...
MDanz Posted July 27, 2010 Author Share Posted July 27, 2010 i tried this but it's not working. <?php echo "<form enctype='multipart/form-data' action='rapidinsert.php' method='post' id='Add'> <br /><br /> <font color='#D99C29' face='Arial' size='3px'>Add Noun </font><input type='text' name='noun' value='' size='30' /> <input type='submit' value='Submit' style='font-size:10px' /> <div onclick='Addform()'>Add Form</div> </form>"; ?> <script type="text/javascript"> function Addform(){ var container = document.getElementById('Add'); var newfield = document.createElement('input'); newfield.type = 'text'; newfield.id = someCounter+'_suffix'; container.appendChild(newfield); } </script> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 27, 2010 Share Posted July 27, 2010 You do realize that dynamically adding/duplicating a form on a page would serve no clear useful purpose because you can only fill in and submit one form on a page. If you had the original plus two dynamically produced duplicates, you can only fill in one of them and submit it, you might as well just fill in the first one that was already there and not bother with the dynamically produced ones. However, if you are trying to dynamically add fields to a form, that makes sense and there are countless examples posted all over the Internet. Which are you trying to do? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.