Created
July 28, 2015 17:30
-
-
Save byronferguson/9d7abdb1338bccd46919 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<div class="form-group"> | |
<label for="schoolLevel">Which school are you currently attending?</label> | |
<select name="schoolLevel" id="schoolLevel" class="form-control"> | |
<option value="0"></option> | |
<option value="1">High School</option> | |
<option value="2">Home School</option> | |
<option value="3">2yr College</option> | |
<option value="4">4yr College</option> | |
<option value="5">Other</option> | |
<option value="6">Not Attending</option> | |
</select> | |
</div> | |
<div id="HSgroup" class="hide"></div> | |
. | |
. | |
. |
This file contains hidden or 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
"use strict"; | |
var $schoolLevel = $('#schoolLevel'); | |
var $HSgroup = $('#HSgroup'); | |
var $homeGroup = $('#homeGroup'); | |
var $collegeGroup = $('#collegeGroup'); | |
var $otherGroup = $('#otherGroup'); | |
var $schoolLevel = $('#schoolLevel'); | |
function showAll() { | |
$HSgroup.removeClass('hide'); | |
$homeGroup.removeClass('hide'); | |
$collegeGroup.removeClass('hide'); | |
$otherGroup.removeClass('hide'); | |
} | |
function hideAll() { | |
$HSgroup.addClass('hide'); | |
$homeGroup.addClass('hide'); | |
$collegeGroup.addClass('hide'); | |
$otherGroup.addClass('hide'); | |
} | |
$(function() { | |
$schoolLevel.change(function() { | |
var selection = $(this).val(); | |
switch(selection) { | |
case 1: | |
hideAll(); | |
$HSgroup.removeClass('hide'); | |
break; | |
case 2: | |
hideAll(); | |
$homeGroup.removeClass('hide'); | |
break; | |
case 3: | |
case 4: | |
hideAll(); | |
$collegeGroup.removeClass('hide'); | |
break; | |
case 5: | |
case 6: | |
hideAll(); | |
$otherGroup.removeClass('hide'); | |
break; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment