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 HTML qn=== Urgent!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML qn=== Urgent!!!" Watch "HTML qn=== Urgent!!!" New topic
Author

HTML qn=== Urgent!!!

Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Hi,
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
<FORM >
<INPUT size="20" type="text">
</FORM>
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
Maya
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
look at this:
http://www.dynamicdrive.com/dynamicindex11/submitonce.htm
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

Al,
interesting, but i don't think that is exactly what he/she meant since the form has neither a submit or a reset button.
maya,
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

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

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

SCJP
Visit my download page
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Randell,
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
Maya
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
www.investext.com, click login, then view source.
look at the getRetPress(e) code & adapt to suit.
Simon
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: HTML qn=== Urgent!!!
 
Similar Threads
one jsp to another
writing jsp codes
servlet or jsp page with prefilled forms
converting dropdown into an editable dropdown
Problem in Validating array of form field