aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Form is submitting more than once" Watch "Form is submitting more than once" New topic
Author

Form is submitting more than once

Rod Bailey
Greenhorn

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";
document.forms[0].submit();
}
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?
Rod
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61421
    
  67

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sathya Bala
Greenhorn

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');
tb1.style.visibility = "hidden";
tb2.style.visibility = "visible";
document.MyForm.submit();
};

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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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: http://aspose.com/file-tools
 
subject: Form is submitting more than once