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

259
Vistas
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 Respuestas
Responde la pregunta

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 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