Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > One click on a form submits twice!

Reply
Thread Tools

One click on a form submits twice!

 
 
Ken Adams
Guest
Posts: n/a
 
      03-16-2005
Basically I have a form that looks something like the following: The form is
contained in the file subscriptAdd.jsp so I want to submit the form to
itself and do some jsp validation after it's submitted, but for some reason
I noticed that two request are being make on each click. Any suggestions.
Thanks

<form name="add" action="<%= response.encodeURL("subscriptAdd.jsp") %>"
method="POST" onsubmit="return checker()">

<input type="submit" value="Submit">

</form>




 
Reply With Quote
 
 
 
 
hyweljenkins@hotmail.com
Guest
Posts: n/a
 
      03-16-2005

Ken Adams wrote:
> Basically I have a form that looks something like the following: The

form is
> contained in the file subscriptAdd.jsp so I want to submit the form

to
> itself and do some jsp validation after it's submitted, but for some

reason
> I noticed that two request are being make on each click. Any

suggestions.
> Thanks
>
> <form name="add" action="<%= response.encodeURL("subscriptAdd.jsp")

%>"
> method="POST" onsubmit="return checker()">
>
> <input type="submit" value="Submit">
>
> </form>


What does checker() do? Odds are that's the problem. What does
subscriptAdd.jps do? Mind you, you haven't posted enough of your code
for anyone to do more than guess the answer. Thinking about it, don't
post your code here - provide a URL instead.

--
Hywel

 
Reply With Quote
 
 
 
 
Augustus
Guest
Posts: n/a
 
      03-16-2005

"Ken Adams" <(E-Mail Removed)> wrote in message
news:noRZd.37843$ZO2.11322@edtnps84...
> Basically I have a form that looks something like the following: The form

is
> contained in the file subscriptAdd.jsp so I want to submit the form to
> itself and do some jsp validation after it's submitted, but for some

reason
> I noticed that two request are being make on each click. Any suggestions.
> Thanks
>
> <form name="add" action="<%= response.encodeURL("subscriptAdd.jsp") %>"
> method="POST" onsubmit="return checker()">
>
> <input type="submit" value="Submit">
>
> </form>
>


saying that it looks "something like the following" and then including a
tiny snippet of code isn't going to be much for people trying to help you
(we'll have to ask "is this the actual code? how "like" the real thing is
the above? Is there something else that could be causing the problem?
Whats in 'checker()'?). A working link to your web page with the form would
be much better.

Odds are your problem is the part:
onsubmit="return checker()"

instead you probably want:
onsubmit="return checker(); return false"

That might fix it up


 
Reply With Quote
 
Lachlan Hunt
Guest
Posts: n/a
 
      03-19-2005
Ken Adams wrote:
> Basically I have a form that looks something like the following: The form is
> contained in the file subscriptAdd.jsp so I want to submit the form to
> itself and do some jsp validation after it's submitted, but for some reason
> I noticed that two request are being make on each click. Any suggestions.
> Thanks


URL?

> <form name="add" action="<%= response.encodeURL("subscriptAdd.jsp") %>"
> method="POST" onsubmit="return checker()">


You should generally include the output HTML, not your JSP when asking
about an HTML related question. Though, in this case it appears as
though the output will be action="subscriptAdd.jsp".

There is no reason why that code would make anything submit twice,
unless the JavaScript function has something to do with it. Check that
function checker() isn't doing any unnecessary form submissions. Other
than that, it's most likely an error with your JSP back end coding.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
 
Reply With Quote
 
Sagar@1 Sagar@1 is offline
Junior Member
Join Date: Jan 2013
Posts: 1
 
      01-22-2013
I am facing the same issue. My jsp page is like this.

<form method="post" name="MyForm" action="/servlet/ibs.servlets.MyServlet">


<TR id="buttons"><td align="right" colspan=2 class="clsdetsub"><A class=clsinfo href="javascript:yesPage()">Confirm</A>

function yesPage()
{
var tb1 = document.getElementById('buttons');
var tb2 = document.getElementById('aftersubmit');
tb1.style.visibility = "hidden";
tb2.style.visibility = "visible";
document.MyForm.submit();
};

Sometimes click on Confirm, submits the form twice. How it is happening? Wat is the solution to resolve this? Pls help.....
 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form no longer submits - client validator problem? Wysiwyg ASP .Net 2 04-25-2005 11:18 PM
autoselect all items in <SELECT> control is undone when form submits Mad Scientist Jr ASP .Net 1 03-05-2004 08:56 PM
Linkbutton submits the form but OnClick event does not get fired Stan ASP .Net 1 12-03-2003 03:11 AM
Run JavaScript before Form Submits Scott M. ASP .Net 14 11-18-2003 09:28 AM
Help needed with form submits and Perl handling Robert V Perl 1 07-21-2003 05:00 AM



Advertisments