One click on a form submits twice!

K

Ken Adams

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>
 
H

hyweljenkins

Ken said:
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.
 
A

Augustus

Ken Adams said:
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
 
L

Lachlan Hunt

Ken said:
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.
 
Joined
Jan 22, 2013
Messages
1
Reaction score
0
jsp form submtting twice

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.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top