Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
Disable button if checkbox is checked and label is a specific text

I have a table with a datagrid (checkboxes and labels in each row). I want to disable a button by checking if a label is "Forbidden". The user can check multiple checkboxes. So my question is how do I get all the checked checkboxes and then check if the label in each selected row is of value "Forbidden" so I can disable the button.

I tried something like this:

$(function() {
    checkboxes = document.querySelectorAll('[id=checkId]');
    var validateBtn = $('button[name="btnVal"]');
    checkboxes.forEach((cb) => {
        cb.addEventListener('change', checkStatus);
    });
    function checkStatus() {
        //to-do
        // if ($(this).is(":checked")) {
            
            var label = document.getElementById('statusLabel');
            if (label.textContent == "Forbidden") {
                validateBtn.prop('disabled', true);
            }
        }
    });

The table looks like this:enter image description here In this case the button should be disabled as we have selected a forbidden status.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can check the property of the checkbox and disable the button according to this will be:

$('#id_of_your_checkbox').click(function() {
    if ($(this).is(':checked')) {
        $('#id_of_your_button').attr('disabled', 'disabled');
    } else {
        $('#id_of_your_button').removeAttr('disabled');
    }
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda