• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Carey Brown
  • Frits Walraven

Form is submitting more than once

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";
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?
Posts: 67389
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
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";

Sometimes click on Confirm, submits the form twice. How it is happening? Please help.....
Posts: 15385
  • 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.
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
Two software engineers solve most of the world's problems in one K&R sized book
    Bookmark Topic Watch Topic
  • New Topic