Created
April 18, 2016 16:25
-
-
Save rionmonster/d5dfdcf09396afe4ef01551405bf513f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Inline approach */ | |
function showDiv(elem){ | |
// If your value is not "Select", then show the next option | |
document.getElementById('stepsHIDDEN').style.display = (elem.value != 'Select') ? "block" : "none"; | |
// If your value is "foo", then show another element | |
document.getElementById('showMeOn42').style.display = (elem.value == '42') ? "block" : "none"; | |
} | |
/* Switch statement approach */ | |
function showDiv(elem){ | |
switch(elem.value){ | |
case 'Select': | |
// Handle logic if 'Select' is selected | |
document.getElementById('stepsHIDDEN').style.display = 'none'; | |
break; | |
case '1': | |
// Handle logic if '1' is selected | |
break; | |
default: | |
// If your value is neither 'Select' or '1', do something | |
document.getElementById('stepsHIDDEN').style.display = 'block'; | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment