Estoy intentando agregar un campo de texto llamado Iniciales y en función de lo que el usuario ingresa en, por ejemplo, el campo de texto fName onkeyup autocompletar el campo de texto de iniciales usando solo el primer carácter.
Aquí está mi intento patético, necesito ayuda
<!DOCTYPE html> <html> <body> <p> </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>prueba esto
var sWord = document.getElementById('fName').value; document.getElementById('Initials').value= sWord.charAt(0); La entrada tiene la propiedad .value en lugar de .textContent