p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_forms thread: Re: Preventing mulitple submits


Message #1 by Greg Griffiths <greg.griffiths@g...> on Wed, 06 Feb 2002 19:50:26 +0000
Try :



<html>

<head>

<script language='javascript'>

var submitted=0;

function validateForm()

{

         if (submitted==0)

         {

                 document.testForm.submit();

                 submitted=1;

         }

}

</script>

</head>

<body>

<form name='testForm' method='post' action='mycode.asp' onsubmit='return 

validateForm()'>

<input type='text' name='info' size='30'>

<input type='submit'>

</form>

</body>

</html>



At 20:48 04/01/02 +0000, you wrote:

>I have a site that depends on the integrity of the data submitted to it. 

>This site is

>going to go live very soon and I have found a really annoying problem.

>

>SCENARIO:

>The FORM: User answers a question and SUBMITS using Method="POST"

>

>RECEIVING PAGE.

>The question is marked and the answer is added to their personal log (TABLE)

>

>This is easy to do BUT !!

>

>If you continually press the submit button then the score is continually 

>added to the log,

>thus making the data useless.

>

>As the user can only answer one question once, I decided to include:

>

>If questionID=(The questionID in a cookie) Then

>         Redirect the page to the question page, and answer another question

>Else

>         Make the questionID(Cookie) equal to questionID

>End the If

>

>I thought this would work, but it doesn't. I also can't find a way of 

>emptying the FORM

>collection, once the data has been accepted once in ASP.

>

>I have also tried to think of a way to include an reset string in 

>Javascript that I can

>insert into Onsubmit, or into OnUnLoad

>

>HELP, Please

>

>Paulk Bucknell

>

>

>

>

>---

>Change your mail options at http://p2p.wrox.com/manager.asp or to 

>unsubscribe send a blank email to $subst('Email.Unsub').




  Return to Index