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

139
Visualizações
How to display text typed into input box immediately after being typed

What i'm trying to do is to display text immediately i type them into an input box,so far my javascript function doesn't even work at all,i just need the function to show when a text is typed into or erased in the text boxes.

<!DOCTYPE html>
<html>
<head>
    <link href="styles.css" rel="stylesheet">
    
</head>
<body>
<div class="output-box">
   <P class="Output-text"></P>
   <P class="Output-text2"></P> 
</div>

<div class="forms">
    <form action="POST">
        <label class="label" for="name">First Name:</label>
        <input type="text" id="name" name="name" onchange="GetAndDisplayInput()">
        <br>
        <br>
        <label class="label" for="name">Last Name:</label>
        <input type="text" id=" last-name" name="name" onchange="GetAndDisplayInput()">
    </form>
</div>
<script>
    function GetAndDisplayInput(){
    var inputFirstName= document.getElementById("name").value;
    var inputLastName= document.getElementById("last-name").value;
    document.getElementsByClassName("Output-text").innerHTML = inputFirstName;
    document.getElementsByClassName("Output-text2").innerHTML = outputFirstName;
}
</script>
</body>








</html>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try use the oninput event listener instead of onchange:

https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/oninput

This will fire immediately after every change, as opposed to every time the element is blurred (unfocused / clicked away).

Example

function display() {
  document.querySelector("p").innerText = document.querySelector("input").value;
}
<input oninput="display();" placeholder="Type in some text">
<p></p>

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