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

119
Visualizações
How to enable dropdown box on value change in person textarea

I have a dropdown disabled by default. I want to enable it when the the textarea person field is not empty.

When the textarea person field value is removed, the dropdown field should be emptied and disabled.

Current code which is not working:

    $('[id*="DDL"]').prop('disabled', true);

$('[id*="User"]').click(function () {
        if (!$(this).is(":empty"))
        {
           $('[id*="DDL"]').prop('disabled', false);
        } 
        else {
           $('#DDL').prop('selectedIndex', 0);
           $('[id*="DDL"]').prop('disabled', true);
        }
});

What am I doing wrong here?

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

0

Let's say you have this HTML

<textarea name="hello"></textarea> <!-- Example name = hello -->
<select name="DDL" id="DDL" disabled></select> <!-- Dropdown -->

In your js file, you can capture if the user types something on the textarea by using keyup, validate if that textarea is empty then do something if it is

jQuery

$(document).on("keyup","[name=hello]", function () {
    if($("#DDL").val() == ""){ // Check if textarea is empty
        $("#DDL").prop("disabled", false); // Remove disabled attrib
        // Do things here
    }
});
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