# Else if statement not working

**URL:** <https://forum.kirupa.com/t/else-if-statement-not-working/196609>\
**Category:** Uncategorized\
**Created:** [August 9, 2006, 7:43pm UTC](https://forum.kirupa.com/t/else-if-statement-not-working/196609 "2006-08-09T19:43:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![littlepowell](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@littlepowell](https://forum.kirupa.com/u/littlepowell)\
**Post date:** [August 9, 2006, 7:43pm UTC](https://forum.kirupa.com/t/else-if-statement-not-working/196609/1 "2006-08-09T19:43:19Z")

</div>

Here’s my code:

Global variable \_level0.menu\_2 is populated with one of 5 values. Function exists for each value. The function for the value should only be called if the \_level0.menu\_2 variable matches the value. What is happening is that even though \_level0.menu2 is correctly populated, only the first if statement executes–even if the first condition is NOT met.

I looked all around and can’t figure out what’s wrong. As far as I can tell (and I’ve been over the code character for character) the syntax is correct.

function loadMenu2():Void{  
if (\_level0.menu\_2 = value1){  
trace("\_level0.menu\_2 is value1");  
value1();  
}  
else if (\_level0.menu\_2 = value2){  
trace("\_level0.menu\_2 is value2");  
value2();  
}  
else if (\_level0.menu\_2 = value3){  
trace("\_level0.menu\_2 is value3");  
value3();  
}  
else if (\_level0.menu\_2 = value4){  
trace("\_level0.menu\_2 is value4");  
value4();  
}  
else if (\_level0.menu\_2 = value5){  
trace("\_level0.menu\_2 is value5");  
value5();  
}  
else {  
trace(“no value selected”);  
}  
}

HELP!
