jono Posted February 1, 2006 Share Posted February 1, 2006 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 More sharing options...
aspnetguy Posted February 1, 2006 Share Posted February 1, 2006 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 More sharing options...
jono Posted February 1, 2006 Author Share Posted February 1, 2006 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(); <{POST_SNAPBACK}> Not accurate enough... Link to comment Share on other sites More sharing options...
aspnetguy Posted February 1, 2006 Share Posted February 1, 2006 try giving your search button the lowest index number of all the other buttons...that should make it click when return is pressed. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now