Mihai Popescu Posted July 20, 2007 Share Posted July 20, 2007 In my application I have a page with a form which has two buttons. For the case when an user wants to complete the form and press enter, I use a javascript to set the focus on the desired button that would ensure a natural flow in my page (I do this exactly when the user press the enter key). This button happens to be the second button in the form. I did some checking and right before the submit is made, the focus is still on that button. But this is still ignored in Opera. The submit is made on the first button. This behaviour apears only on Opera. In IE, FF and Safari everithing works fine, meaning that the submit is made on the active button. First of all I want to know if someone has encountred this issue. I realize that I can't get too much help without showing any code, but I apreciate any opinion. About the code... I'm not sure that I'm allowed to show it. Link to comment Share on other sites More sharing options...
d3bruts1d Posted August 13, 2007 Share Posted August 13, 2007 Can't say much without the code... but you could try something like this on your input fields: onkeypress="if (event.keyCode == 13) {document.formname.submit();}" Code would look something like this: <input name="q" type="text" id="q" onkeypress="if (event.keyCode == 13) {document.formname.submit();}" size="30" maxlength="100" autocomplete="off" /> What this will do, is if the user presses enter while in that specific field, it'll submit the form. Link to comment Share on other sites More sharing options...
Recommended Posts