If using load

0

I have the following function in javascript:

$(document).ready(function () {
    Eventos();
  $('[name="dtd1nrob"]').change(function () {
        BloquearQuestao();
    });
});


function Eventos() {
    BloquearQuestao(true);
};

function BloquearQuestao(load) {
    load = load || false;

    if (!load) {

    }

    var value = $('[name="dtd1nrob"]:checked').val();
    if (value == '1') {
        $('[name="dtd1"]').prop("disabled", true);
        $('[name="dtd1"]').val('');
    } else {
        $('[name="dtd1"]').prop("disabled", false);
    }
}

The variable dtd1nrob is a checkbox that when it is selected it disables and clears the variable dtd1 , when I select the variable dtd1nrob and save the form until everything is ok, but when I come back on the form, the variable dtd1 is not disabled but the dtd1nrob variable is selected, could someone help me?

    
asked by anonymous 09.03.2017 / 15:46

1 answer

0

I was able to solve my problem and put all the functions inside the document.ready

$(document).ready(function () {
    Eventos();
  $('[name="dtd1nrob"]').change(function () {
        BloquearQuestao();
    });

function Eventos() {
    BloquearQuestao(true);
};

function BloquearQuestao(load) {
    load = load || false;

    if (!load) {

    }

    var value = $('[name="dtd1nrob"]:checked').val();
    if (value == '1') {
        $('[name="dtd1"]').prop("disabled", true);
        $('[name="dtd1"]').val('');
    } else {
        $('[name="dtd1"]').prop("disabled", false);
    }
}

});
    
09.03.2017 / 16:38