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

145
Vistas
Auto add first Char in Textfield based on Entered Value

I am attempting to add a textfield called Initials and based on what user enters in say fName textfield onkeyup auto complete initials textfield using first character only.

Here's my pathetic attempt, need help

<!DOCTYPE html>
<html>
<body>

<p>&nbsp;</p>
<p>Enter your name: 
  <input name="fName" type="text" id="fname" onkeyup="showFirstChar()">
</p>
<p>Initials: 

  <input name="Initials" type="text" id="Initials">    
  <script>
    function showFirstChar() {
        var sWord = document.getElementById('fName').innerHTML;
        document.getElementById('Initials').innerHTML = sWord.charAt(0);
    }
  </script>
  
</p>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

try this

var sWord = document.getElementById('fName').value;
document.getElementById('Initials').value= sWord.charAt(0);

Input has .value property instead of .textContent

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