Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 24th, 2006, 10:05 AM
Umesh
Guest
 
Posts: n/a
Default Page Submits Twice

Hi

Here is the sample code for my form, but problem is that it submitts
twice in some cases when i click sub mit button.


<script>
function validateform (){
//do a lot validation here, if validation failes, return false;

//finaly this line
return true;
}
</script>

<form name="abc" action="any other apge" onsubmit = "return
validateform();">



<input type="submit" name="save" id="save">
</form>

Can any one help me?

  #2  
Old February 24th, 2006, 10:05 AM
Paxton
Guest
 
Posts: n/a
Default Re: Page Submits Twice


Umesh wrote:[color=blue]
> Hi
>
> Here is the sample code for my form, but problem is that it submitts
> twice in some cases when i click sub mit button.
>
>
> <script>
> function validateform (){
> //do a lot validation here, if validation failes, return false;
>
> //finaly this line
> return true;
> }
> </script>
>
> <form name="abc" action="any other apge" onsubmit = "return
> validateform();">
>
>
>
> <input type="submit" name="save" id="save">
> </form>
>
> Can any one help me?[/color]

You need to ask this in a javascript forum. It's a client side problem
- ASP is purely server side.

/P.

  #3  
Old February 24th, 2006, 10:15 AM
Umesh
Guest
 
Posts: n/a
Default Re: Page Submits Twice

Any way! thanks for suggestion

  #4  
Old February 25th, 2006, 03:45 AM
dNagel
Guest
 
Posts: n/a
Default Re: Page Submits Twice

<script>
var isSubmitted = false;
function validateform (){
//do a lot validation here, if validation failes, return false;
//finaly this line
if (!isSubmitted)
isSubmitted=true;
return true;
else
return false;
}
</script>

<form name="abc" action="any other apge" onsubmit = "return validateform();">
<input type="submit" name="save" id="save">
</form>
  #5  
Old February 25th, 2006, 07:45 AM
Umesh
Guest
 
Posts: n/a
Default Re: Page Submits Twice

Hi ! Thanks for your time.

I am not able to understand why this probelm occured. can u elaborate
more.

**Note submit button is clicked only once.

  #6  
Old February 25th, 2006, 10:15 AM
Evertjan.
Guest
 
Posts: n/a
Default Re: Page Submits Twice

dNagel wrote on 25 feb 2006 in microsoft.public.inetserver.asp.general:
[color=blue]
> if (!isSubmitted)
> isSubmitted=true;
> return true;
> else
> return false;[/color]

=== Do not forget the {}

....
if (!isSubmitted) {
isSubmitted=true;
return true;
}
else
return false;
....

=== why use "else":

....
if (!isSubmitted) {
isSubmitted=true;
return true;
}
return false;
....

=== why use an "if":

....
var x = isSubmitted
isSubmitted = true
return !x
....

;-}

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles