Javascript – JSP: two submit button on the same form


I have two submit buttons on the same form in JSP page, one of each appear in the form depending on the case.

The problem is that one of the submit buttons submit the form, and the other does not .

here's the HTML form

       <form  name="stdActivationForm"  id="stdActivationForm" action="ParentManagementServlet" method="post" onsubmit="return validateStudentActivationForm()">
            <input class="${isActivated? 'hideDiv':'showDiv'}" type="submit" value="confirm"  name="submit" onclick="submitForm('add')"/>
            <input class="${parent != null? 'showDiv':'hideDiv'}" type="submit" value="update"   name="submit"  onclick="submitForm('update')"/>


and here's the javascript function

  function submitForm(btnName)
            var form = document.getElementById("stdActivationForm");
            if (btnName =='add')
            else if(btnName =='update')

Best Solution

I think your JavaScript function needs to return true. Alternatively you can just remove the onclick reference and it should work with just type="submit".

Good luck.