kvarnerexpress 0 Report post Posted May 9, 2005 Ive got a form, with a submit button on the left and a submit button on the right. By default on the enter keypress, the form submits the left submit button, but i want it to submit the right button. How would i accomplish this? kvarnerexpress Share this post Link to post Share on other sites
SystemWisdom 0 Report post Posted May 9, 2005 You should only have one submit button (type="submit") and make the other button a normal button (type="button") which has its own onclick event handler..Example: <html><head><script language="JavaScript"><!--function doSubmit( e ){ var keyCode = (window.Event) ? e.which : e.keyCode; if( keyCode == 13 ) document.forms[0].submit();}function doSomethingElse(){ alert("Something else");}//--></script></head><body><form name="MyForm"><input type="text" name="blah" value="" onkeypress="doSubmit(event)" /><input type="button" value="Some Button" onclick="doSomethingElse()" /><input type="reset" value="Clear" /><input type="submit" value="Submit" /></form></body></html> I hope that helps! Share this post Link to post Share on other sites
Mike 0 Report post Posted May 15, 2005 Or you could simply add an extra field to the code used to produce the submit button. Your submit button is probably <input type="submit" name="blah" value="Blah" />, but you can add an extra field that makes it so the user could click ALT then another letter or number to get it to work. For example: <input type="submit" name="blah" value="blah" accesskey="r" /> would make it so if the user pressed down on ALT + 4, the button would b e clicked. Share this post Link to post Share on other sites