473,394 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

OnKeyUp

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
1 2149
acoder
16,027 Expert Mod 8TB
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

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

Similar topics

3
by: Trent | last post by:
Hi. I know the basic way to assign event handlers: <input onKeyUp="processEvent(event)" /> But how do I assign a function to the onKeyUp event in *javascript* that can access the event...
2
by: Evan Wong | last post by:
I have problem to get onkeyup event. If we put the event in HTML statement like - "<input name=field1 size=16 onkeyup="javascript:function1();>" it works. If we put in JavaScript code like...
2
by: greg | last post by:
hello i would like to apply an onkeyup event to every element of my form in order to do that, i would use the array form.elements, doing something like that : ...
2
by: john.lum | last post by:
My overall objective is to create something akin to Google Suggest, where a query is done in response to changes in a text field presented to the user. I've got things working using the onkeyup...
3
by: Brad | last post by:
The first text on my form is a numeric field. I have a javascript that runs on this field for onkeyup (validate the key strokes and modifies fields on the screen) but when I do this and have the...
13
by: Lee | last post by:
I have this function that doesn't work. I pass it the td element and an id, and it makes an input field inside the td. That part workds. What doesn't work is that I want to add an "onkeyup" on...
6
by: kodt | last post by:
I have a form with 4 text input fields. The last one is the total of the previous three fields and should automatically calculate this value when a user enters data into any of the first 3. ...
2
by: mc | last post by:
Can someone suggest how I would add a new trigger such that when the JS event onkeyup in a textbox the updatePanel refreshes? If not could someone sugest how I could onkepup in a Textbox, refresh...
7
pragathik
by: pragathik | last post by:
hi, I have my source code like this <INPUT type="text" ID="t1" ONCHANGE="foo()" ONKEYUP="foo();boo();"> <SCRIPT> function foo(){ //some code } function boo(){
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.