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

consequetive events + global variables

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>
Jul 23 '05 #1
1 2141
In article <46**************************@posting.google.com >,
lu**********@hotmail.com (Sandman) wrote:
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?

Perhaps the page was being reloaded. When you go to a new page then
press the back arrow, you get up your original page. The page is
reloaded. This sets the variable something to true. Some browsers will
let the form data filled in. You can now press enter to submit the form
and you will see the original value of true in the global variable.

The alert in the onblur event may have had a bit of a side effect or I
have not used enough alerts to know all the features. When I filled in
the data then clicked on the submit button, I got the onBlur alerts, but
the script didn't move directly to the submit form events. In IE on the
mac, the IE window lost focus. I had to click on the window to gain
focus. Once I clicked, the submit event ran. Netscape 7.1, I had to do
a second click in Netscape 7.1 too.

You canceled the submit which made it hard for me to follow what was
going on. When I put in a valid action and changed return to true. I
didn't see any problems with the setting of the variable something.
Robert
Jul 23 '05 #2

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

Similar topics

3
by: Derek Basch | last post by:
Is it bad form to use the global window variable to reference an event handlers window? Like so: function SortableTable() { oFilterAdd = this.document.createElement("button");...
9
by: MLH | last post by:
open form in design view then allow it to be opened into form view from code. then set its visible propery to false then open into design view from code then set its visible propery to false...
33
by: MLH | last post by:
I've read some posts indicating that having tons of GV's in an Access app is a bad idea. Personally, I love GVs and I use them (possibly abuse them) all the time for everything imaginable - have...
3
by: Dennis | last post by:
I have a global variable that I set in one procedure that is called from one event. There are also some events such as getfocus, lostfocus, etc. that are triggered for another control that get...
9
by: Nathan Sokalski | last post by:
I have a very simple UserControl which contains an Image and a Label, which I use to display an image with a caption. I am using this control inside a DataList, setting the two Public variables...
9
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
11
by: giddy | last post by:
hi , ok , i have a programming background but i'm new to C# . i'm also self taught so : i have a datagridview that should act differently depending on which user has signed in now is it...
5
by: Sandman | last post by:
I dont think I understand them. I've read the section on scope in the manual inside out. I'm running PHP 5.2.0 Here is the code I'm working on: //include_me.php <?php $MYVAR = array(); global...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.