Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

257
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda