bgallegos Posted June 24, 2006 Share Posted June 24, 2006 Hello,I'm creating a pet prescription website that requires account creation by the customers. During the account creation process, the customer needs to be able to put in their pet(s) information along with the veterinarian's information.Currently the form displays an area for the first pet's information. Below this I would like to have a button that says "Add Another Pet." When the user clicks on this button, I would like another area of the form to be created for another pet. I do not want the page to refresh, but to add the next part of the form right below the previous section. The button will then be moved down below the new section.Will javascript be able to do this for me?Thanks Link to comment Share on other sites More sharing options...
scott100 Posted June 24, 2006 Share Posted June 24, 2006 Yes this is what javascript is good for Just hide the section you don't wan't to be shown, then when the button is clicked show the section.Here's an example to get you started <body><form><p>Pet name<input type="text" /></p><p>Type of pet<input type="text" /></p><div id="ap" style="display:none"><p>Another Pet's Details<input type="text" /></p></div><p><input type="button" value="Add another pet" onclick="ap.style.display='block'" /></p><p><input type="submit" value="submit" /></p></form> Link to comment Share on other sites More sharing options...
aleksanteri Posted June 24, 2006 Share Posted June 24, 2006 Well that could work... but if the owner has 3+ pets?You should create a span area and every time when clicking on a button, it adds a control to the span area.I could write the code for you but I can't get it working. However, I found this page that has the code you need. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now