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

253
Visualizações
Cambiar el valor de un TEXTO DE ENTRADA marcando una casilla de verificación

¿Por qué esto no funciona? Se supone que funciona de esta manera: si la casilla de verificación está marcada, debe tomar el contenido de una variable txt y escribirlo en la entrada con la identificación de show.

 function myFunction() { if (document.getElementById('myRadio').checked) { var txt = "Done"; document.getElementById("show").innerHTML = 'txt'; } }
 <p>If the radio checkbox is checked the text from the variable text is written into input line with the ID of show</p> <input type="checkbox" onclick="myFunction()" id="myRadio"> <br> <br> <input type="text" class="form-control" id="show">

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

0

Debe establecer la propiedad de value del elemento de entrada, no el innerHTML :

 function myFunction() { if (document.getElementById('myRadio').checked){ var txt = "Done"; document.getElementById("show").value = txt; } else { document.getElementById("show").value = ''; } }
 <p>If the radio checkbox is checked the text from the variable text is written into input line with the ID of show</p> <input type="checkbox" onclick="myFunction()" id="myRadio"> <br> <br> <input type="text" class="form-control" id="show">

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