By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,265 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

JavaScript - onKeyPress, onKeyUp

P: 55
Hello
I have an input box and a button that runs a function taking the input as a parameter. The button click works fine. The problem is it needs to respond to the enter key. I have it responding to the enter key, but in both ff and ie it loads the function produces the correct output, but then it looks like the page refreshes and the output is gone.

Suggestions?

Expand|Select|Wrap|Line Numbers
  1. function test(e)
  2. {
  3.  
  4.     var e = e.keyCode
  5.     if (e == 13)
  6.     {
  7.         findit();
  8.         alert("Hi!")
  9.  
  10.     } 
  11. }
  12.  
Jun 14 '08 #1
Share this Question
Share on Google+
1 Reply


100+
P: 428
default browser behavior is to submit a form if there is a single input text element and enter is pressed.

set the form's onsubmit method to return false,
and call its submit() directly when you want to upload the form.
Jun 14 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.