javascript - Expand if statement -
the code snippet below created have hide or show dropdowns depending on selected. in case below:
**translation** if modelyear <= 67 , assyplant=bf or modelyear >=68 display following dropdowns etc.
what expand on stating following:
if modelyear <=67 , assyplant =bf or modelyear <=67 , assyplant =bc or modelyear >=68 display following dropdowns etc etc etc.
already have following working code:
// model_year + assy_plant logic if (thisfield == 'model_year' || thisfield == 'assy_plant') { var modelyear = parseint($('#model_year').children('option:selected').text()); if (isnan(modelyear)) { return; } var assyplant = $('#assy_plant').children('option:selected').text(); $('tr#row6').css('display', 'none'); $('tr#row7').css('display', 'none'); $('tr#row6 select').attr('disabled', 'disabled'); $('tr#row7 select').attr('disabled', 'disabled'); if (((modelyear <= 67 && assyplant.tolowercase()) == 'bf') || modelyear >= 68) { $('tr#row6').css('display', 'table-row'); $('tr#row6 select').removeattr('disabled'); } else { $('tr#row7').css('display', 'table-row'); $('tr#row7 select').removeattr('disabled'); } }
it have add additional assyplant values in future. time.
you can use jquery.inarray() check if assyplant
1 of possible values.
var assyplants = ['bf', 'bc']; // expandable list of assyplant values check if ((model_year <= 67 && jquery.inarray(assyplant.tolowercase(), assyplants)!==-1) || model_year >= 68) { ...
Comments
Post a Comment