I have a form in an ASP page that has four SUBMIT buttons, each for a different potential user action. The form also contains a text INPUT field.
For usability reasons, I would like to send a click event to a particular SUBMIT button when the user types into the text field and presses the Enter key.
The way it is now, when the user presses Enter, another one of the SUBMIT buttons gets a click event (not the one I want).
Here is the code in question. I would like the "Go" button to be acted upon, but the "Done" button is currently the one being sent to the processing script. An "onblur" event does not do the trick. It catches when the user tabs out of the text box, but not when they press Enter.
Dave Gee
For usability reasons, I would like to send a click event to a particular SUBMIT button when the user types into the text field and presses the Enter key.
The way it is now, when the user presses Enter, another one of the SUBMIT buttons gets a click event (not the one I want).
Here is the code in question. I would like the "Go" button to be acted upon, but the "Done" button is currently the one being sent to the processing script. An "onblur" event does not do the trick. It catches when the user tabs out of the text box, but not when they press Enter.
Code:
<FORM method="POST" action="DoBlueCardAction.Asp" name="cmd">
<INPUT type="hidden" name="cns" value="<%=nCNS%>">
<TABLE border="0" width="80%" cellspacing="0" cellpadding="0">
<TR>
<TD align="left">
<HR>
<INPUT type="submit" value="Done" name="Done" tabindex="6">
<INPUT type="submit" value="Page 2" name="Page2" tabindex="5">
</TD>
<TD align="center">
<HR>
<%
' Decide whether to show the Next/Prev buttons
SQLCountPrev = "SELECT Count(*) AS c FROM pdoximport.BCImport WHERE CNS_No < " & nCNS
SQLCountNext = "SELECT Count(*) AS c FROM pdoximport.BCImport WHERE CNS_No > " & nCNS
rs1.Open SQLCountPrev, cn
if rs1("c") > 0 then
%><INPUT type="submit" value="<<Prev" name="Prev" tabindex="4"><%
end if
rs1.Close
rs1.Open SQLCountNext, cn
if rs1("c") > 0 then
%><INPUT type="submit" value="Next>>" name="Next" tabindex="3"><%
end if
rs1.Close
%>
</TD>
<TD align="right">
<HR>
<INPUT type="text" name="NewCNS" value="<%=nCNS%>" size="8" align="right" tabindex="2">
<INPUT type="submit" value="Go" name="Go" tabindex="1">
</TD>
</TR>
</TABLE>
</FORM>
Dave Gee