473,387 Members | 1,621 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,387 software developers and data experts.

Something amis with passing a keyCode to a function

Still getting my webfeet on in understanding the proper syntax for
crafting javascript statements. I've created this function that
ignores the code if the Tab key is pressed... oddly enough it works
just fine in IE and ignores the Tab key like I want it too, but in
Netscape it blows up.... I don't think the Tab key is being passed or
something else is amis. ???
<script type="text/javascript">
function showRemaining(formElement) {
if ((event.keyCode) != 9) {
var theForm1 = formElement.form;
var remainingDisplay = formElement.name + 'Remaining';
theForm1.elements[remainingDisplay].value = formElement.maxLength
- formElement.value.length;
}}
</script>


<input... onkeyup="javascript:showRemaining(this);"
Jul 20 '05 #1
1 1326
ma******@yahoo.com (Matthew) writes:
Still getting my webfeet on in understanding the proper syntax for
crafting javascript statements. I've created this function that
ignores the code if the Tab key is pressed... oddly enough it works
just fine in IE and ignores the Tab key like I want it too, but in
Netscape it blows up.... I don't think the Tab key is being passed or
something else is amis. ???
<script type="text/javascript">
function showRemaining(formElement) {
if ((event.keyCode) != 9) {
Where does the event variable come from? (In IE, it is a global variable,
in most remining browsers and W3C DOM 2 Events, it is not).

I suggest making the event a parameter of the function, i.e.,
---
function showRemining(evt,formElement) {
if (evt.keyCode != 9) {
---

and then:
<input... onkeyup="javascript:showRemaining(this);"


<input ... onkeyup"showRemaining(event,this);">

No "javascript:" in front (why did you think it should be there?),
and pass the event to the function.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matthias Knöchlein | last post by:
hi !! I have the following problem : Is there a function or a constant value to check if a keyCode is a key kile "Shift", "Alt" or "F1". I would like not to use this way : if( ...
1
by: Perttu Pulkkinen | last post by:
I have different functions that receive window.event as parameter. Functions are used like this: <input type="text" id="x" onkeypress="return onKeyCurrencyCheck(ev, 'x')" onblur...
6
by: rich_poppleton | last post by:
Help.... I've got a textarea where people type in a description. However for certain reasons we need to stop them typing !$*^ . I have a solution this which works fine in IE: function...
1
by: shihabca | last post by:
How to determine the keycode in a netscape browser , so that i can allow only numbers to be entered into the textbox. this has to be done without passing any event as argument
5
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate...
4
by: Nathan Sokalski | last post by:
I am writing a piece of code for an ASP.NET function that generates an onKeyPress JavaScript eventhandler that uses the event.keyCode / event.which properties. I have two situations that I would...
3
by: Paul Gorodyansky | last post by:
Hi, I have function that works via onkeypressed - for example, what to catch when a user presses a punctuation symbol such as '.' So I check keyCode for that - works just fine in Opera 8,...
2
dlite922
by: dlite922 | last post by:
got the following code that works great in IE, i have need an exception to these rules. Why to Tab? Users come from old Apps (data entry people) and want to use the enter key to move through...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.