faqts : Computers : Internet : Web : HTML : Forms

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

32 of 50 people (64%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How can I make the 'submit' button to default? [so I can press it using the <ENTER> key]

Nov 12th, 2002 17:43
Alex Ginzburg, Gaby Gyore,


Let's say your form's name is "formA" and it looks something like...


<form name='formA' method='POST' action='http://www.bla.com'>
<input type='text' name='text1'>
<input type='submit' value='Submit'>
</form>


and using an outside textfield, by key event keypress, pressing enter, 
which is ascii code 13, will submit the formA form.

<input type='text' onkeypress='if(event.keyCode==13)
{document.formA.submit();}'>