Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Form is submitting more than once

 
Rod Bailey
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this is not JSP-specific, I'm moving it along to the HTML forum.
bear
 
Sathya Bala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would cancel the click action of the link. And I would not use the href to trigger JavaScript.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic