[thelist] if else if sanity check
Joe Crawford
jcrawford at avencom.com
Wed Sep 12 17:25:50 CDT 2001
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