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

131
Visualizações
Display value in input in html

I have the following code for html:

<label for="">Input</label>
<input type="text" name="" id="input_01" placeholder="Enter some text">

<label for="">Output</label>
<input type="text" name="" id="ouput_01">

<script>
    var input_01 = document.getElementById("input_01")
    var output_01 = document.getElementById("output_01")
    input_01.addEventListener('keyup',function(){
        output_01.value = input_01.value
    })
</script>

I want to display the input value as the output. However, I found that the command "output_01.value = input_01.value" doesn't work and there is nothing displayed. I do not know why and do not know how to solve this problem. How can I display the content of an input in 'ouput_01'? Thank you.

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

make sure you don't have typo in your code.

change from

<input type="text" name="" id="ouput_01">

to

<input type="text" name="" id="output_01">
about 4 years ago · Santiago Trujillo Relatório

0

your INPUT tag output ID does not match the one on your javascript DOM and this output_01.value = input_01.value is wrong, instead you should add event to your function parameter in your Event Listener then assign your event.target.value to your output DOM value

<label for="">Input</label>
<input type="text" name="" id="input_01" placeholder="Enter some text">

<label for="">Output</label>
<input type="text" name="" id="output_01">

<script>
var input_01 = document.getElementById("input_01")
var output_01 = document.getElementById("output_01")

input_01.addEventListener('keyup', function(event) {
 output_01.value = event.target.value
})
</script>

about 4 years ago · Santiago Trujillo 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