Jump to content

click a button on keydown in textbox


jono
 Share

Recommended Posts

I want a button to be automatically clicked when I press Return in a textbox. Normally some other link will be clicked on Return but I want my search button to be clicked.I have a function that checks if the keyCode is 13 and then tries to click my button by doing this:["document.forms[0].elements['NormalFrameWorkControl:center_middle:SearchBodyControl:btnSearch'].click();]But why won't my button react??/jono

Link to comment
Share on other sites

instead of using

document.forms[0].elements['NormalFrameWorkControl:center_middle:SearchBodyControl:btnSearch'].click();]

give the button an id then use this

document.getElementById('buttonID').click();

or even better

document.forms[0].submit();

Link to comment
Share on other sites

instead of using
document.forms[0].elements['NormalFrameWorkControl:center_middle:SearchBodyControl:btnSearch'].click();]

give the button an id then use this

document.getElementById('buttonID').click();

Works great in Firefox but not in IE 6.0...Will IE need some special javascript code?or even better

document.forms[0].submit();

Not accurate enough...
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...