If using load

Asked

Viewed 38 times

0

i have the following javascript function:

$(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 dtd1nrobis a checkbox that when it is selected disables and clears the variable dtd1, when I select the variable dtd1nrob and save the form so far everything ok, but when I return in the form, the variable dtd1 is not disabled but the variable dtd1nrob is selected, someone could help me ?

  • Question seems quite like this: If Load javascript

  • So it’s the same pretty much just that I went to do the tests today and it didn’t solve, it still comes disabled

  • What is load? What you call the function BloquearQuestao?

  • updated the topic

  • Do console.log(value) within the function BloquearQuestao and see the values being considered.

  • is returning the value 1 name="dtd1nrob" value="1"

  • Okay, I’m already there!

Show 3 more comments

1 answer

0

Guys I managed to solve my problem I put all the functions inside the ready Document.

$(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);
    }
}

});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.