I run a website on a java servlet, which load my jsp page and, under this function, I have a condition that verifies if a button in my jsp is clicked (all in the doGet):
this.getServletContext().getRequestDispatcher(jsp file here);
//...
if (request.getParameter("valeur0") != null){
//do stuff
}
Then, in my jsp file, my html button, when clicked, calls a javascript function like this:
<input type="submit" name="valeur1" value="Bouton 1" id="myBtn1" onclick='startCombine()'/>
Where startCombine() is defined by:
function startCombine() {
document.getElementById("myBtn1").disabled = true;
}
When I don't call the startCombine() function (so there's no onclick in my button declaration), the stuff in the servlet condition works. However, when I call startCombine() with the onclick in html, even if I click on my button, it never gets into the if...
I tried everything, I can't seem to spot the problem...
It looks like the submit button disables itself (by calling the startCombine
function) before it has a chance to submit the form. And if the form is not submitted... your servlet is not called !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.