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 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How do I clear a form after validation and submittal.

    I have a web form for viewers to complete and submt. I have written a javascript function which ensures that all fields are filled in prior to submittal. I have also written the ASP code which processes the form and writes the content to a database. So far, so good. The problem is that I have noticed that many viewers, for whatever reason, choose to hit the Submit button more than once. This, of course, results in multiple, identical fields in the database. I don't think it would do any good to write a statement at the bottom of the form instructing viewers to hit the Submit button only once. This would stop some from riding the Submit button, but
    other would either not notice the statement or just ignore it.

    What I am really looking for is a way to clear the form after the fields have been validated and the the form content has successfully been written to the database. I can write code which will validate the form AND clear the fields after submittal, but the problem is that the fields are cleared before
    the entries can be written to the database. It seems that the best way to accomplish this is to have the form clear after a delay.

    Has anyone encountered this problem in the past? Any ideas?

    Thanks,
    petela
    Attached Files Attached Files

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts

    Go with server-side solution not with client-side solution

    I didn't bother to check the attachments because they are Word docs.

    But my suggestion to you is to check the multiple submissions in the server-side just like this forum does and/or have the primary key in the table and catch errors when executing the sql insert.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Jan 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, that's the way to do it. Thanks for the reply.

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    or you can set a flag after the insert.

    like setting a sessionvariable when the insert is made + check at the top of the page if that sessionvariable is set before you proces the form.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    New Coder
    Join Date
    Jan 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply.

    petela


  •  

    Posting Permissions

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