Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript - onfocus() problem

 
Dinesh Bang
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic