[thelist] if else if sanity check

spinhead evolt at spinhead.com
Wed Sep 12 17:36:28 CDT 2001


Not that I didn't trust you (you know I trust you, right Joe?) I popped this
into a page, and, just as expected, it fired the first true condition, then
stopped.

Thanks for the sanity check. I'm too close to a window, and it's hot in
here, and I'm not completely sane right now.

spinhead


----- Original Message -----
From: "Joe Crawford" <jcrawford at avencom.com>
To: <thelist at lists.evolt.org>
Sent: Wednesday, September 12, 2001 3:18 PM
Subject: Re: [thelist] if else if sanity check


> spinhead wrote:
> > (It's JavaScript, but I'm really looking for the overall concept)
> >
> > When an if-then finds a true condition to act on, does it exit, or could
it
> > continue checking for other true conditions? I've got an bit more or
less
> > like this:
> >
> > If type = computer Then
> >     do the computer stuff
> >     ElseIf
> >     type = test Then
> >     do the test stuff
> >     ElseIf
> >     total > limit Then
> >     go somewhere totally different
> > End If
> >
> > If type = computer AND total > than limit, and the required actions
aren't
> > mutually exclusive, would it do both, or do the first, then exit? I've
> > always assumed it would just do the first, then quit checking.
>
> else if is mutually exclusive in javascript. try this code in a browser:
>
> <script type="text/javascript" language="JavaScript">
> <!--
> if (1==1) {
> //do the computer stuff
> alert(1);
> } else if (2==2) {
> //type = test then
> //do the test stuff
> alert(2);
> } else if (3==3) {
> //total > limit then
> //go somewhere totally different
> alert(3);
> };
> //-->
> </script>
>
> I think it checks and the first one that passes gets fired. For the
> example above, I get an alert of 1.
>
> HTH,
> Joe <http://artlung.com/>
> --
> ...................  Joe Crawford \\ Web Design & Development
> .....  mailto:jcrawford at avencom.com \\ http://www.avencom.com
> .... San Diego \\ CA \\ USA \\ AVENCOM: Set Your Sites Higher
>
>





More information about the thelist mailing list