View Full Version : designating a button through 'ENTER'

03-09-2005, 11:26 PM
I have 2 submit buttons. Without rearranging the order of the buttons, how can i make the enter (return) button submit the submit button i want?

03-10-2005, 12:25 AM
Can you post some code?

03-10-2005, 08:09 AM
<form action='page' method='post'>
<input type='text' name='variable'>
<input type='submit' value='Enter 1' onClick='action()'>
<input type='submit' value='Enter 2'>

Obviously just an example. But I would want button 'Enter 2' to be submitted when they hit return on their keyboards, not 'Enter 1'. How?

(I cant rearrange them)

03-10-2005, 08:29 AM
something like <form onLoad="document.form.button2.focus()">

btw, name your buttons!

03-10-2005, 10:45 PM
In my actual script they are named.

Will the point of giving it focus be lost once they click inside another field?