This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes submit a form when you hit 'enter' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "submit a form when you hit Watch "submit a form when you hit New topic
Author

submit a form when you hit 'enter'

Chitra Jay
Ranch Hand

Joined: May 02, 2002
Posts: 76
Hi,
How do I make a form submit the values upon hitting enter in the textbox?
In the webpage, there are 2 textfields username & password and a go button (which is a actually an image).
when the user hits 'enter' on the password field, the form should submit values.
Code Snippet:
<form action="/Online/logon.aspx" name="thisForm" id="thisForm" method="post">
<td><img src="pix/user_name.gif" alt="Username" width="49" height="25" border="0"></td>
<td width="80"><input tabindex="1" type="text" name="username" value="" size="10"></td>

<td><img src="pix/password.gif" alt="Password" width="49" height="25" border="0"></td>
<td width="80"><input tabindex="2" type="password" name="password" size="10"></td>

<td width="25"><a href="/Online/logon.aspx" onKlick="document.thisForm.submit(); return false;" tabindex="3">
<td><img src="pix/go.gif" alt="Go" width="25" height="17" border="0"></a></td>
</form>

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

How do I make a form submit the values upon hitting enter in the textbox?


Make sure that the form has a submit button.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nila dhan
Ranch Hand

Joined: Sep 15, 2005
Posts: 160
try this

<input type="image" value="submit">
Chitra Jay
Ranch Hand

Joined: May 02, 2002
Posts: 76
thanks!! that worked
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: submit a form when you hit 'enter'
 
Similar Threads
reg html tables
JSP Help Regarding the Radio Button
HTTP Status 405 error
How to Pass, Username and password and Login from the url
How to include servlet response in a JSP?