Enable input when entering a select

Hello good, I am trying to enable an input when selecting a data from a select, I have everything declared, but I do not know why it does not work for me

<script src="{{asset('assets/js/formacionprofesional/habilitarInput.js')}}"></script>

Select:

 <select class="form-control select2 select2-hidden-accessible" name="grado_academico" id="grado_academico">
                                                        <option value="">Seleccionar un grado academico</option>
                                                        <option value="1">Magisteer</option>
                                                        <option value="2">Doctorado</option>
                                                        <option value="3">Posdoctorado</option>
                                                        <option value="4" selected>Otros</option>
                                                    </select>
                                                    <input id="input" disabled="disabled" type="text">

JS

$(document).ready(function() {
    $('#grado_academico').change(function(e) {
        if ($(this).val() === "4") {
            $('#input').prop("disabled", true);
        } else {
            $('#input').prop("disabled", false);
        }
    })
});

Hi @nikoveloso15, it works for me – after selecting anything other than “Otros”, the input field gets enabled:

Are you getting any errors in the console?

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.