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

OnKeyUp

P: 2
I would like to have a help function installed. I want the user to be able to press F2 in any text box on an HTML form and have a pop up window appear with various text pertaining to that textbox.

In my test textbox, I have the following code:
onkeyup="help_function(event,name); this.select()"

where name is the name of the text box and the JavaScript function is named help_function()

In the JavaScript file, I have the following code:
Expand|Select|Wrap|Line Numbers
  1. var unicode = e.keyCode? e.keyCode : e.charCode
  2. if(unicode == 113)
  3. {
  4. //113 is the F2 key
  5.      if(name=="sku")
  6.      {
  7.         . . . code for help goes here . . . 
  8.       }
  9. }
  10.  
There are two problems:
1. I would like to replace the second if statement in the JavaScript code with a select statement. I probably have a typo with this logic and this is not that important since I only have 5 textboxes.
2. When the user types in one character in this test textbox, the entire field is selected and only one character can be entered. For what it's worth, I do have the following code in my HTML document:
<body onLoad = "document.form1.sku.focus()">

The sku textbox is my test textbox.

If you need any additional information, please let me know. I am not a beginner but not an expert at JavaScript so you may have to explain some things in depth.

Thanks for your time.
Jan 1 '09 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
1. I think you mean a switch statement.

2. Check the length of the input if you want to avoid the whole field being selected after only one letter before calling this.select().
Jan 3 '09 #2

Post your reply

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