I have a problem with a javascript global variable, let's suppose I have the following
var globalVar;
I have a text field
<input type="text" id="myInput" onkeydown="checkKey(this)" onkeypress="checkKey(this)"/>
And in the function checkkey, I assign some value to it:
globalVar=document.forms[0].elements("myInput").value;
I checked the the global variable value has changed with an alert.
When I try to use globalVar
in another function, I find it has the value undefined. The other function has something like:
param += globalVar;