Soy bastante nuevo en Javascript. Estoy tratando de agregar un elemento de formulario a mi página de resultados de Javascript Quiz.
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); }Lo que estoy tratando de hacer es seguir la página de resultados que muestra "su puntaje es". Necesito un elemento de formulario para que los usuarios ingresen sus iniciales y envíen.
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); // 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);Intenté esto y funcionó. Gracias @MrCano369