Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

odd submit behavior with only one text box  RSS feed

 
K Dombroski
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have searched and searched and can find no explanation for the odd behavior I am seeing on one of my pages. I am using Struts 1.2.7 and browsing using IE 7.0.5730.11.

On my page, I have a html:text field and a html:submit button (and some other buttons). If I hit enter while my cursor is in the text field, the page is submitted WITHOUT activating the submit button (or any other buttons), which is not the behavior I want, as I need to check to see if the submit button has been clicked in order to know what actions to take.

Another interesting thing I discovered is that if I add another text field or password field to the page, everything works great. But if it is any other type of input, it does not work, and if I remove the extra input, it doesn't work. There does not appear to be anything special about the text field. In fact, it seems to be if I have only one text field, regardless of which field it is, I see this odd behavior. As soon as I have two text fields, everything works great. It also does not seem to matter if they are struts text boxes or standard html text boxes.

If I remove all of the text fields, leaving only the submit button, hitting enter does absolutely nothing. This kind of makes sense, though, as even when there are text boxes on the page, hitting enter does nothing if I don't have my cursor in one of the text boxes.

Does anyone have an explanation for this? A way to make it work? I am at my wit's end on this. Thanks for any insight.
 
K Dombroski
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I just found the answer to my own question: it's an IE bug. Apparently, IE does not trigger a button if there is only one text box in the form. Why is anyone's guess.

For anyone else who happens to run across the same problem, the solution is to add a text box that has the style set to "display: none" so it will not show up on the page.

http://frustratedprogrammer.blogspot.com/2004/07/ie-bug-and-struts-forms-with-one-input.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!