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

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

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 Report

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