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

106
Vistas
Append form to a result page in Javascript

I am pretty new to Javascript. I am trying to add a form element to my Javascript Quiz results page.

function viewResultPage() {
    console.log("viewResult Page: ", currentQuestionIndex, " ", timeleft);
    // inner html Sets or returns the content of an element
    welcometxt.innerHTML = ""
    var allDoneEl = document.createElement("span");
    allDoneEl.innerHTML = "Quiz is over and final score is: " + timeleft;
    welcometxt.appendChild(allDoneEl);
    // Create a form
    const f = document.createElement("form"); 
    // Add it to the document body
    document.body.appendChild(f); 
    

           
    
}

What I am trying to do is following the results page showing "your score is " I need a form element for the users to enter their initials and submit.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

const f = document.createElement("form");

//Add an input element to form
const input = document.createElement("input");
f.appendChild(input);

// Add it to the document body
document.body.appendChild(f); 
about 4 years ago · Juan Pablo Isaza Denunciar

0

 // create a form for accepting the initial
    var inputForm = document.createElement("form");
    inputForm.setAttribute("id", "inputForm");

    //Add an input element to form
    var inputText = document.createElement("input");
    inputText.setAttribute("type", "text");
    inputText.setAttribute("id", "initialstext");
    inputText.setAttribute("placeholder", "Enter your initials");
    inputForm.appendChild(inputText);

    // Add it to the document body
    scoresSection.appendChild(inputForm);
    // create a button for submitting the form
    var submitBtn = document.createElement("button");
    submitBtn.setAttribute("id", "submitBtn");
    submitBtn.setAttribute("style", "float: center; position: relative;");
    submitBtn.innerHTML = "Submit";
    scoresSection.appendChild(submitBtn);

I tried this and it worked. Thank you @MrCano369

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