[Javascript] Avoid multiple onclick
Paul Novitski
paul at juniperwebcraft.com
Tue Nov 7 17:30:34 CST 2006
At 11/7/2006 11:06 AM, Guillaume wrote:
>This is perfectly working... This function will work once only...
>However how do I allow that function to run again once another
>function has been called ?
>
>var bInitialized = false;
> ...
> function DoSomething()
> {
> if (bInitialized) return;
> bInitialized = true;
>
> ...
> }
>
>
> function DoSomethingElse()
> {
> // Need to re-enable the function above to run again
>
> ...
> }
Guillaume,
Since bInitialized is a global variable, you can set it to true or
false at any point in your logic. To free the DoSomething() function
again, simply execute:
bInitialized = false;
in another function.
If more of your functions have these on/off switches, you might
consider creating custom objects in which the function is a method
and the on/off switch is a public property.
Regards,
Paul
More information about the Javascript
mailing list