File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes HTML qn=== Urgent!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML qn=== Urgent!!!" Watch "HTML qn=== Urgent!!!" New topic

HTML qn=== Urgent!!!

Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
I have a jsp (test.jsp) with a form having a single text box,
Now I focus the text box and click enter button of the key board and I am seeing, my page(test.jsp) getting called again.
This is the code
<INPUT size="20" type="text">
Now instead of having one text box, if I have 2 textboxes, then my page wont be called again and again..
What is the difference here and how do I make my test.jsp with a single text field not to do resubmits ???
Please help
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
look at this:
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

interesting, but i don't think that is exactly what he/she meant since the form has neither a submit or a reset button.
what could that form possibly be for? it has no way to submit it and no action to do if there was a submit.
to answer your question as best i can, i dont know exactly why it acts that way, but if you added a hidden field to your form with only one text element it should act like the second form

<INPUT size="20" type="text">
<input type="hidden">

[ August 27, 2002: Message edited by: Randall Twede ]

Visit my download page
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
I tried adding a hidden object before posting this, still it doesnt work!!!
My actual page has an image instead of a Submit button, with an href to the action page. But according to the requirements, the users want to submit the form, both by pressing the enter key and by pressing the image button.
When I press the image, the form doesnt get submitted, but when I press enter key, the form gets submitted..
Any idea of how do I prevent the form getting submitted.... ???
Al, Thanks for the link, but it doesnt solve the problem this time.. any other suggestions
SJ Adnams
Ranch Hand

Joined: Sep 28, 2001
Posts: 925
In a form with one text field the return key is treated as a submit. With more than one text box the return key does not do anything - you must add a handler.
If you want to use a submit key as well as return take a look at, click login, then view source.
look at the getRetPress(e) code & adapt to suit.
I agree. Here's the link:
subject: HTML qn=== Urgent!!!
It's not a secret anymore!