title: Passing Localstorage data to MySQL
body: <p>I have two local storage variable that keeps count of the user score during a quiz and the number of questions. They are called <code>userMark</code> and <code>questionCounter</code> respectively. </p>
  
  <p>Upon completing a quiz, I parse the localstorage variables as a float and then determine percentage score (userMark/questionCount * 100).</p>
  
  <p>When the user finishes the quiz, the score is displayed. However, I would also like to send this data to a MySQL DB, via a PHP file called <code>marks.php</code> but I would like to do this in the background without the need for clicking a button.   After being sent, I would like to clear the localstorage variables.</p>
  
  <p>Is there a way of sending this data without having a form?</p>
  
  <p>Here's what i've got so far:</p>
  
  <pre><code>    &lt;script&gt;    
              // Get LocalStorage Variables and parse as float.
  
              userMark_float = parseFloat(localStorage.getItem("userMark"));
              questionCounter_int = parseFlat(localStorage.getItem("questionCounter")); 
  
              // Calculate Percentage Score
  
              percentage = (userMark_float/questionCounter_float) * 100;
              percentageMark = percentage.toFixed(1);
  
              // Display Percentage score &amp; userScore/totalScore.
  
             document.getElementById("percetangeMark").innerHTML = percentageMark;
             document.getElementById("userMark").innerHTML = userMark_int;
             document.getElementById("questionNumber").innerHTML =questionCounter_int;
  
  
             // Code for Sending Percentage Mark to MySQL
  
  
  
             // Clear Local Storage
             localStorage.removeItem("userMark");
             localStorage.removeItem("questionCounter");
     &lt;/script&gt;
  </code></pre>