aspose file tools
The moose likes Struts and the fly likes question on changing focus Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "question on changing focus " Watch "question on changing focus " New topic
Author

question on changing focus

Nandu Raghu
Greenhorn

Joined: Nov 21, 2003
Posts: 12
Hi,
I have 2 textboxes and one checkbox. When I click on the checkbox, I want to do some validation and then put the focus on textbox 1 if the validation fails. I am not clear on how to change the focus back to the textbox 1.
Any help will be appreciated.
Thanks.
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
use javascript form onLoad method to see if there is any error to make the focus for the form to the check box. that will work.


Adios
Nandu Raghu
Greenhorn

Joined: Nov 21, 2003
Posts: 12
Thanks for your response, Sandy.
I am still not clean how the onLoad handler would help me in this case. Can you please explain a little more.
Thanks.
Franck Tranchant
Ranch Hand

Joined: Aug 07, 2003
Posts: 75
This is basically a JavaScript problem.
Right after your validation, probably in the OnChange() method of your checkbox, you could add javascript similar to this :
<...>
document.forms["form_name_here"].elements["textbox1_name_here"].focus();
<...>
Then textbox1 should get the focus...


Franck<p>--------------------
Nandu Raghu
Greenhorn

Joined: Nov 21, 2003
Posts: 12
Thank you FrancK.
It worked !!
[ November 27, 2003: Message edited by: Nandu Raghu ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: question on changing focus
 
Similar Threads
Render Problem
validation for textbox
java script
How to use focus() command
Javascript or vbscript and ASP