We have one issue to solve the bugs come back by clients yesterday. The problem is when our client change quantity in input box of the item and press enter, this item is oddly disappeared from the main screen. So, I need to troubleshoot this issue and read through this code again. Obviously, I found that there are two submit buttons in this found.

If there are two submit buttons in a form, do you know which submit button will work when we press enter?

view plain print about
1<form name="frmDoubleSubmit" method="post" action="index.cfm">
2    <input type="Text" name="txtName"><br>
3    <input type="Submit" name="btnDelete" value="Delete">
4    <input type="Submit" name="btnSave" value="Save">    
5</form>

Oddly, this action goes to the first submit button of this form called "Delete". How to prevent it? I found that there is two ways to prevent.

  • One is move submit Delete button after Save button.
  • Two is add javascript function.

Here is second solutions.

view plain print about
1[script]
2    document.onkeyup = KeyCheck;     
3    
4    function KeyCheck()
5    {
6     var KeyID = event.keyCode;
7     if (KeyID == 13)
8         document.frmDoubleSubmit.btnSave.click();
9    }
10[/script]