Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

105
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda