Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!