File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Enter Key & submit Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Enter Key & submit" Watch "Enter Key & submit" New topic
Author

Enter Key & submit

Annmarie Ziegler
Greenhorn

Joined: Apr 06, 2001
Posts: 21
I was wondering if anyone could help with what is probably a simple thing, but my brain is fried at this point. I'm not sure if it's an html or js issue.
I have a screen (one form) that displays a text field and a 'search' button, among other things. When I click the 'search' button all works great. When I enter a value in the text field and hit enter with focus still in the input field I was expecting the 'search' button action to be executed -- it is not. But if I click on the screen anywhere after the search button and hit enter, it submits as though search was clicked.
The following is a partial snippet of my html. I am using struts, hence the html:text tag.
Thanks in advance,
Annmarie
...
<html:form method="post" action="/allCompaniesListDispatchAction.do">
<table border="0" cellpadding="3" cellspacing="0" class="filter>
<tr>
<td width="126" class="filterLabel">Jump To Company</td>
<td width="50" class="filterValue">
<html:text property="jumpToCompanyIdInput" value="" size="10" maxlength="10" styleClass="filterValue" on k eypress="capitalize;" />
</td>
<td width="73" class="filterLabel>
<input type="image" name="" id="search" src="search_green.gif"
on click="setValues('search', jumpToCompanyIdInput.value);"
width="73" height="22">
</td>
<td><img src="spacer.gif" width="10" height="1"></td>
</tr> </table> ....
</html:form>
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
if you want to use the enter key you are going to have to use a onSubmit of the form tag. Here is the basic idea.

<form name="blah" onSubmit="return jsFunction()">
your script would be
function jsFunction(){
//your code andyou need to return true or false
//return false
//return true
}
Annmarie Ziegler
Greenhorn

Joined: Apr 06, 2001
Posts: 21
Thanks. I do have a onSubmit on the form ... I'll try again.
am
 
 
subject: Enter Key & submit
 
Threads others viewed
Submit Form and Enter Key
Problem Passing Parameter values to action
Problem in hiding the row of data
two forms on one jsp.
How to call jquery method in Struts.
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com