• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Form is submitting more than once

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since this is not JSP-specific, I'm moving it along to the HTML forum.
bear
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.....
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would cancel the click action of the link. And I would not use the href to trigger JavaScript.
 
reply
    Bookmark Topic Watch Topic
  • New Topic