Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes Javascript - onfocus() problem 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 "Javascript - onfocus() problem" Watch "Javascript - onfocus() problem" New topic
Author

Javascript - onfocus() problem

Dinesh Bang
Ranch Hand

Joined: Jun 15, 2006
Posts: 52
Hi Ranchers,

I am using a jsp which have multiple input text boxes, a Search button (submit action) and a Advance Search (another submit button).
Now whenever user clicks on any of input box a javascript onfocus is called to Focus the Search button. But the first of submit button i.ee in my case Advance search button always gets focus. As it comes first on UI.
Is there any way to specifically mention which button to foucs ?


SCJP 1.4,SCBCD 1.3, SCWCD 1.5, ???
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I am not sure what you are talking about here. Are you focusing the button or are you talking about the browser's default behavior?

Eric
Dinesh Bang
Ranch Hand

Joined: Jun 15, 2006
Posts: 52
To elobrate,

I have input search text field. And two buttons label "Advance Search" and "Search". Both the are of type "submit"
Now in the jsp (JSF) file , the "Advance Search" button comes first and then the "Search" button.
When the user clicks input text are, the first button of "submit" type gets focus. Is there a way to specify which button should get focus by default?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
The form will select whatever comes next. You can look into tab index, but I doubt it will make a difference with default submit action.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javascript - onfocus() problem
 
Similar Threads
How to keep a button from submitting a form.
JSF Variable State: Odd Behavior
Ajax Calls not refereshed.
major problem with html:cancel and html:submit
Set focus to a label field