Below you find a small test page.
I contains an input box, with an onBlur event, and a form, with an
onSubmit event.
When I place the cursor in the text box and push ENTER, first the
onBlur event and then the onSubmit event is raised.
The onBlur event displays the value of the global variable [true], it
changes the value of the global variable to [false] and displays it
again [false].
The onSubmit event simply displays the value of the global variable
[true], which is the original value, not the new. Huh?
Why doesn't the onSubmit event notice that the global variable has
changed?
<html>
<head>
<script language="javascript">
var something = true;
function BlurFunc() {
alert('begin BlurFunc: ' + something);
something = false;
alert('begin BlurFunc: ' + something);
}
function SubmitFunc() {
alert('begin SubmitFunc: ' + something);
return false;
}
</script>
</head>
<body>
<form name="frmTest" method="post" action="steven.asp"
onSubmit="return SubmitFunc();">
<input type="text" name="test" onBlur="BlurFunc();">
<input type="submit">
</form>
</body>
</html>
I contains an input box, with an onBlur event, and a form, with an
onSubmit event.
When I place the cursor in the text box and push ENTER, first the
onBlur event and then the onSubmit event is raised.
The onBlur event displays the value of the global variable [true], it
changes the value of the global variable to [false] and displays it
again [false].
The onSubmit event simply displays the value of the global variable
[true], which is the original value, not the new. Huh?
Why doesn't the onSubmit event notice that the global variable has
changed?
<html>
<head>
<script language="javascript">
var something = true;
function BlurFunc() {
alert('begin BlurFunc: ' + something);
something = false;
alert('begin BlurFunc: ' + something);
}
function SubmitFunc() {
alert('begin SubmitFunc: ' + something);
return false;
}
</script>
</head>
<body>
<form name="frmTest" method="post" action="steven.asp"
onSubmit="return SubmitFunc();">
<input type="text" name="test" onBlur="BlurFunc();">
<input type="submit">
</form>
</body>
</html>