I have created a simple quiz in an HTML-document, and I want to display the score in another HTML-document. How do I place a variable from a script file to an element in an HTML file?
This is my Javascript code, with most of the if-statemnts edited out (they are all the same):
var score = 0;
function start(){
if (document.getElementById('radio13').checked){
score ++;
}
if (document.getElementById('radio23').checked){
score ++;
}
var finalscore = score *10;
var results = "Your score is: " + finalscore + " %.";
window.location.replace("quizresults.html");
document.getElementById('presult').innerHTML = results;
}
The new page loades, but it is empty. This is the HTML-code for the result-page where I wish to add the score:
<div id="main">
<p id="presult"></p>
</div>
quizresults.html.