I am trying to find the best way to have a different function happen on change of my select box.
This is my select HTML
<select name="event-recurring">
<option selected="true">None</option>
<option value="daily">Daily</option>
<option value="weekly">Weekly</option>
<option value="monthly">Monthly</option>
</select>
My jquery is:
$('select[name=event-recurring] option:selected').change (function (){
//Will Do Something
});
How Do I tell it do something different on the different values?
Solution:
$('#event-recurring').change(function (){
var $select = $(this);
switch($select.val()) {
case "daily":
$('#recurring-options').remove();
$("<div id='recurring-options' class='row'><label>Choose:</label>Choose a Date</div>").insertAfter('#recurring');
break;
case "weekly" :
$('#recurring-options').remove();
$("<div id='recurring-options' class='row'><label>Choose:</label>Weekly</div>").insertAfter('#recurring');
break;
case "monthly":
$('#recurring-options').remove();
$("<div id='recurring-options' class='row'><label>Choose:</label>Monthly</div>").insertAfter('#recurring');
break;
default:
$('#recurring-options').remove();
break;
}
});