Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Updating a form dynamically

    I want to create a form which allows a person to insert a multipage article into my database. When the form page load initially there is only one textarea for the first page of the article. I want there to be buttons (links preferably, but I don't think that's possible) called "Add new page" and "Delete last page" which update the form. The thing is, when someone clicks one of those "form updating" buttons, I don't want the information in the other form fields to be lost (which is what would happen if the page reloads). I also don't want the new content saved to my database when one of those buttons is clicked. I want the content saved to my database only when the submit button is clicked. How could I go about doing this? If it's not possible, is there a better way to achieve the same thing?

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Yes, it's possible.

    The attached file is one I did for our company intranet; it allows users to create a new "job" on the system. Among other things, it records the step details for the job: a job might consist of a number of steps, each of which can be assigned a category, description and a cost.

    So when a user clicks "start a new job", opening this page, they get initially one "row" of boxes for the step details - a select box for the category, a textarea for the description and a text input for the cost.

    They can then click "Add more details" and they get another, identical set of boxes to fill in. They can carry on doing this till their fingers fall off.

    If there's more than one row of boxes, they also get a "Delete the last row" button.

    When they finally hit "Submit", it (and it could be a bit better here, but it works) concatenates each row into a string, and then concatenates all those strings into one uber-string, and drops that into the database.

    So - have a look at the file, it's a bit more complex than what you want I think but you can strip a lot of it out. The main areas you need are around line 100 (where the "addrow" and "deleterow" javascripts are), and around line 600, which is where the table containing the step details is.

    Hope it's some help.
    Attached Files Attached Files

  • #3
    New Coder
    Join Date
    Jul 2002
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Would you please briefly state what method you used so that I know what I'm looking for? Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •