<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
John,<br>
<br>
Yep, so simple and working... Thanks !!<br>
I was trying the same but with:<br>
<pre>var bInitialized = false; </pre>
Wich strangely was not working.<br>
Regards.<br>
Guillaume.<br>
<blockquote cite="mid02e801c702bd$2ef8cbc0$4701a8c0@earth" type="cite">
<pre wrap=""> function DoSomethingElse()
</pre>
<blockquote type="cite">
<pre wrap=""> {
// Need to re-enable the function
above to run again
...
</pre>
</blockquote>
<pre wrap=""><!---->bInitialized = false; // <<<-------------
</pre>
<blockquote type="cite">
<pre wrap=""> }
</pre>
</blockquote>
<pre wrap=""><!---->
John Warner
</pre>
<blockquote type="cite">
<pre wrap="">-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:javascript-bounces@LaTech.edu">javascript-bounces@LaTech.edu</a>
[<a class="moz-txt-link-freetext" href="mailto:javascript-bounces@LaTech.edu">mailto:javascript-bounces@LaTech.edu</a>] On Behalf Of Guillaume
Sent: Tuesday, November 07, 2006 2:07 PM
To: [JavaScript List]
Subject: Re: [Javascript] Avoid multiple onclick
Paul,
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
...
}
</pre>
<blockquote type="cite">
<pre wrap="">At 10/18/2006 01:59 AM, Guillaume wrote:
</pre>
<blockquote type="cite">
<pre wrap="">So what I'd like is the functions to fire only once even if onclick
is performed multiple times.
</pre>
</blockquote>
<pre wrap="">
One method of preventing a function from running more than
</pre>
</blockquote>
<pre wrap="">once is to
</pre>
<blockquote type="cite">
<pre wrap="">set a global variable the first time the function is called, and
refuse to run if that variable is set:
var bInitialized = false;
...
function DoSomething()
{
if (bInitialized) return;
bInitialized = true;
...
}
Regards,
Paul
_______________________________________________
Javascript mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Javascript@LaTech.edu">Javascript@LaTech.edu</a>
<a class="moz-txt-link-freetext" href="https://lists.LaTech.edu/mailman/listinfo/javascript">https://lists.LaTech.edu/mailman/listinfo/javascript</a>
</pre>
</blockquote>
<pre wrap="">_______________________________________________
Javascript mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Javascript@LaTech.edu">Javascript@LaTech.edu</a>
<a class="moz-txt-link-freetext" href="https://lists.LaTech.edu/mailman/listinfo/javascript">https://lists.LaTech.edu/mailman/listinfo/javascript</a>
</pre>
</blockquote>
<pre wrap=""><!---->
_______________________________________________
Javascript mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Javascript@LaTech.edu">Javascript@LaTech.edu</a>
<a class="moz-txt-link-freetext" href="https://lists.LaTech.edu/mailman/listinfo/javascript">https://lists.LaTech.edu/mailman/listinfo/javascript</a>
</pre>
</blockquote>
<br>
</body>
</html>