This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Submitting with Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Submitting with "Enter" from textbox where there are several submit buttons on form" Watch "Submitting with "Enter" from textbox where there are several submit buttons on form" New topic
Author

Submitting with "Enter" from textbox where there are several submit buttons on form

J P Nelson
Greenhorn

Joined: Dec 16, 2004
Posts: 12
Hi all,

I have a form that has several submit buttons, each with a different name. My JSP code uses the name to figure out how to process the forms. The forms basically allow the user to page through a list of data.

On each form, I have a textbox associated with a submit button that allows the user to jump to a specific page in the data, the page is specified by the value entered in the text box.

My users want to enter the page number in the text field and then hit the Enter key to submit it. I've found out how to capture the key press and see that it is the enter key that was pressed (keyPress == 13...).

If its the enter key, I can call submit, but is there then a way to fool the application into thinking that the corresponding submit button was pressed? Is there a way to set a request paramater associated with the submit action?

Thanks,

Joe
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15362
    
    6
you can try document.forms[0].buttonName.click();

(Not supported in every browser, but it will help)

Other solution would be to set a hidden field on the page with the "string" you are looking for.

Eric
J P Nelson
Greenhorn

Joined: Dec 16, 2004
Posts: 12
Good call.

I'm having to get the element indirectly, but the idea is what I needed.

Thanks!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Submitting with "Enter" from textbox where there are several submit buttons on form
 
Similar Threads
hitting the enter on the keyBoard should default to "YES" button on the html/jsp page
2 buttons listening for the same key
Stop Textfield from Going Blank
how to recognize that which button is pushed
"enter key" button focus ?