0

I am new to html/javascript/CSS and I am trying to make a score page for a quiz I am making. I am having the issue that on my score page, although I have a working alert that displays the number I want, when I try to put it into the inner HTML nothing happens. I am getting the number from the URL and it would be formatted like "address.com/blah?=9". I am not sure if my error is a fundamental error or a basic syntax error. The code is meant to display the number in the URL right before the /10 any help is much appreciated, Thanks!

<!DOCTYPE html>
<html>
<style>
 body{
  background-color: pink;
  text-align: center;
 }
 div{
  display:inline-block;
 }
</style>

<head>
    <title>Submission Form</title>
</head>

<script>
 var x = document.URL;
 var QIndex = x.indexOf("?") + 2;
 var questionCorrect = x.substring(QIndex,QIndex+2);
 alert(questionCorrect);
 document.getElementById("QCor").innerHTML = questionCorrect;
</script>

<body>
    <h1>Thank You</h1>
    <p>Here is your score:</p>
 <div id="QCor"></div>
 <p> /10</p>
 
</body>
</html>

  

0 Answers0