File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes javascript setfocus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "javascript setfocus" Watch "javascript setfocus" New topic

javascript setfocus

charu setia

Joined: Nov 01, 2007
Posts: 4
Hi all,
I have a problem with the javascript page.Its like i have around 76 fields in my Jsp.from Jsp i m calling my javascript page.there some validations are occuring for all the fields.if a user enters some wrong value, say for some 40th field, the error message will appear.when the user clicks "ok", the wrong value entered will be selected but the focus goes to the top og page.i want the focus to come on that particular field.
I am already using select() method for selecting the value.
I also tried with setfocus() and focus(), but of no use.
If anybody can can help me out, plase reply
Thankks in advance
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
One way to do this is to include JavaScript code similar to the following in a function that is executed from the body's onload event.

Unfortunately, if you have 40 different properties, you'll have to repeat this code 40 times.

Consultant, Sima Solutions
I agree. Here's the link:
subject: javascript setfocus
It's not a secret anymore!