473,657 Members | 2,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="javas cript">
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="retur n SubmitFunc();">
<input type="text" name="test" onBlur="BlurFun c();">
<input type="submit">
</form>
</body>
</html>
Jul 23 '05 #1
1 2169
In article <46************ **************@ posting.google. com>,
lu**********@ho tmail.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
2405
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"); oFilterAdd.setAttribute("type", "button"); oFilterAddText = this.document.createTextNode("Add");
9
1492
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 then open into design view from code then set its visible propery to false then open into design view from code
33
3034
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 been for years. If the machine has memory to spare and windows can use it - I'm thinking "Why not?" I was wondering what some of you have to say about that, particularly any severe "gotchas" you've had the unfortunate experience to contend with.
3
1202
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 stacked up that apparently are executed after my procedures exits. The new Global variable value that gets set in this procedure is not recognized by the events that execute after my procedure exits. Instead the old value of the Global Variable is...
9
2307
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 using attributes in the *.aspx page. Everything displays great for the initial load, but whenever I try to add or delete an item (I have controls to do this on the page), it does not seem to be recieving any values for the public variables. Here is...
9
8644
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 Su Gatlin, casual mention was made about using static variables as an alternative to using global variables. This caused me to think of the following: '-----Begin module code
11
1668
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 more effecient/correct if i do this:
5
11811
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 $MYVAR, $a; ?>
1
29342
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 called it polluting the global namespace. This article explores what happens when the global namespace becomes polluted and how to avoid this condition. The opinions expressed in this article are those of the author alone although many have...
0
8305
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7320
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.