Would appreciate any help to a newbie here. I have a simple if/else if statement that for some reason only gets to the second condition, even if the third is met. I’ve tried adding else to the end, tried pretty much everything but still nothing. I know it’s not working, because I added the alert triggers and no matter what it never gets to the third condition. What am I missing here? I’ve looked around a lot so I’m sorry if I’m beating a dead horse here but I couldn’t find a solution. I should note that I’m trying to get the conditions on the change of a selection drop-down box. Thanks!!!
My code:
$('#table_two select:eq(6)').change(function(e){
var allDiv = $('#table_two,#table_three,#table_four');
var parBoxOne = $('#par_one').val();
var totalOne = 1 - parBoxOne;
var totalTwo = 2 - parBoxOne;
if ($(this).val() == "made_shot"){
$(allDiv).hide();
$('#score_one').val(totalOne);
$('#score_total').val($('.score_input').val());
alert('ACE!!');
}
else if ($(this).val() == 'green', 'trees', 'fairway', 'rough', 'sand' ){
$('#score_one').val(totalOne);
$('#score_total').val($('.score_input').val());
$('#table_two').hide();
$('#butt_two').html('Show stroke');
alert('triggered two');
}
else if ($(this).val() == 'other', 'penalty_water', 'penalty_ob', 'penalty_sand' ){
$('#score_one').val(totalTwo);
$('#score_total').val($('.score_input').val());
$('#table_two').hide();
alert('triggered three');
}
});
Just another apporoach: