Programming forums Java Java JSRs Mobile. How to write an event for 'Enter' key? Is there some way to map the enter key with send button??Infact am able to. How To set Default Button for ENTER key pressed. Write javascript which will tap the 'KEY PRESSED EVENT' and equate the hexa-code with 'ENTER' key's hexa-code. In a pop-up window i have a text box on entering data there i hit a button to validate the data, since i use the same script for different purposes, i do not want to post this page on hitting the button, so i pass it as a querystring thru Javascript. Now my problem is on entering data in the text box if i hit a ENTER KEY the text box becomes blank and page does not querystring thru javascript. Rather if i remove the querystring from button and post the page as SUBMIT then the ENTER KEY works fine. I do not want to SUBMIT the page i want it thru Querystring.! Can some body tell me how i can make the ENTER KEY to work as it does while SUBMIT. Thanks in Advance RKSK. HERE I AM AGAIN --------------- 1. The popup window first comes with one text box and OK button (this where i am asking for ENTER KEY) on OK i post the same script and this time 2. It comes with two text box and a OK button the ENTER KEY is not working here too, on OK i post(querysting) the same script and this time 3. It comes with 2 test box and 2 drop down box and OK button. When i post at 1. - i call function OK() when i post at 2. - i call function new_OK() when i post at 3. - i call function final() since i am posting the same script three times i do not want to use ONSUBMIT because when i post for 2 and 3 i call different function, it may go wrong because ONSUBMIT will always go thru function OK(). I tried - the ENTER KEY works fine at 1. ![]() Now and the rest of the script works fine too because the ENTER KEY is not at all responding at 2. (THANKS amit_g) If i make the ENTER KEY to work at 2. Now the -- onsubmit='Ok();return false; will go bad again. Anrussell -- i am still working on your script and yes i have more text boxes.THANKS Thanks RKSK. This is how the browser is supposed to behave. The form is submitted on pressing 'ENTER' key only when a text field is in focus. That is why it doesn't submit the form when a drop down is in focus. You can try few triks here but most of them will annoy the user. For example you can set focus to a form field by having onchange handler of the drop down. You can also submit the form on onchange handler. You can also try to have a onkeypress or onkeyup handler for the dropdown but that might have some cross browser issues. ![]() ![]() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2018
Categories |