File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Form is submitting more than once Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Form is submitting more than once" Watch "Form is submitting more than once" New topic

Form is submitting more than once

Rod Bailey

Joined: Oct 06, 2003
Posts: 4
I have this in my JSP:
<a href="javascript:callLink('N',1)">Next</a>
<a href="javascript:callLink('P',1)">Previous</a>
And this function in my JS file:
function callLink(fnct,runtype)
document.forms[0].functionValue.value = fnct;
document.forms[0].runType.value = runtype;
document.forms[0].action = "/servlet/com.csedge.PendingMergeResultServlet";
document.forms[0].method = "Post";
I need to submit the whole form because of checkbox and text field values. I don't have a submit button on this form. The only way I am submitting is by javascript. It seems to submit twice and I'm not sure why.
Any help?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63532

Since this is not JSP-specific, I'm moving it along to the HTML forum.

[Asking smart questions] [About Bear] [Books by Bear]
Sathya Bala

Joined: Oct 11, 2012
Posts: 2
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'); = "hidden"; = "visible";

Sometimes click on Confirm, submits the form twice. How it is happening? Please help.....
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
I would cancel the click action of the link. And I would not use the href to trigger JavaScript.
I agree. Here's the link:
subject: Form is submitting more than once
jQuery in Action, 3rd edition