mardi 19 avril 2016

Change option select Jquery

i have 2 dropdown, one of these if its true, will hide the another one, look at the code...

$('#seguimiento_requerido').on('change', function() {
    if (this.value == 'Si') {
        $("#seguimiento_requerido_show").show();
    } else {
        $("#seguimiento_requerido_show").hide();
        $("#seguimiento_requerido_show :input").prop("required", false);
    }
});

if the this.value == 'No' it will hide the another dropdown that its called #suministros_s, but #suministros_s option value will keep 'N/A' (as default declared on the HTML)

<select id="suministros_s" name="suministros" class="sm-form-control">
  <option value="Si">Si</option>
  <option value="No">No</option>
  <option value="N/A" selected>N/A</option>
</select>

how do i change the "selected" option on the if loop?

Aucun commentaire:

Enregistrer un commentaire