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

256
Views
Document by ID not connecting

I was recently working on an assignment for my computer class, but I have a connection error within my code. To my knowledge, the function looks correct.

            function idCard(){
            var firstName = document.getElementByID("firstName").value;
            var lastName = document.getElementByID("lastName").value;
            var address = document.getElementByID("address").value;
            
            document.getElementById("postFullName").innerHTML = firstName + "" + lastName;
            document.getElementById("postAddress").innerHTML = address;
            
            var age = document.getElementByID("age").value;
            var phoneNumber = document.getElementByID("phoneNumber").value;
            
            const numberArray = [age,phoneNumber];
            
            for ( var i = 0; i < numberArray.length; i++){
                if (numberArray[i]<=100){
                document.getElementId("postAge").innerHTML = numberArray[i];
                }
                else{
                document.getElementId("postPhoneNumber").innerHTML = numberArray[i];
                }
            }
            
            }

The display works fine, and so far I only get one error from my debugging console,"Uncaught TypeError: document.getElementByID is not a function".

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In JavaScript, Case sensitivity matters,

first 3 lines after the function, it should be getElementById instead of getElementByID, also 6th, 7th line and inside the for loop

innerHTML should work but its usually used to set html, innerText would be a better option

and good luck with your assignments

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!