wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Setting Focus after the form is Submitted 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 "Setting Focus after the form is Submitted" Watch "Setting Focus after the form is Submitted" New topic

Setting Focus after the form is Submitted

m yasmin

Joined: Nov 11, 2008
Posts: 9
Hello All,
I am trying to set the focus on an element after a form is submitted by doing the following:

I cant figure out why the focus is not getting set. However, it works if I remove the submit().

Thanks in advance.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60732

The page goes away when the form is submitted, so there's nothing to set focus to!

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
stef li

Joined: Jan 16, 2006
Posts: 27
you can do nothing any more after you submit the form.

if the system returns the same page after you submit the form, you can set a variable in your request scope.
and check the variable, if it exists then set the focus in the onload method. or do nothing.

This guy is so lazy!!!<br />There is nothing left!
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Do it during the onload or as an inline script of the result.
I agree. Here's the link: http://aspose.com/file-tools
subject: Setting Focus after the form is Submitted
Similar Threads
form being submitted twice
from is getting submitted when 'Refresh' button is clicked
The form Values are not getting set to the Backing bean
form is getting submitted when 'Refresh' button on the browser is clicked.
jquery -- code review comparing original and current values on a form