lundi 4 mars 2019

if statement issues with change

i am want to check dynamic value and variables that is Yes or No:

My HTML is:

<select name="super_attribute[161]" data-selector="super_attribute[161]" data-validate="{required:true}" id="attribute161" class="super-attribute-select" aria-required="true">                      
<option value="">Choose an Option...</option>
<option value="11">REFURB</option>
<option value="12">NEW</option>
</select>

jQuery:

jQuery("select.super-attribute-select").change(function() {
           //console.log("New Product ID: " + this.value);
            var option_id11 = "Yes"; var option_id12 = "No"; 
            var selectedvalue = this.value;

            //var optionvalue = "option_id"+selectedvalue;

            if ("option_id"+selectedvalue=== "Yes") {
                console.log('hide');
            } else if ("option_id"+selectedvalue === "No") {
                console.log('show');
            } else {
                console.log('Nothing');
            }

        });

but its always show Nothing in console. please help

Aucun commentaire:

Enregistrer un commentaire