title: Display localstorage in input on load
body: <p>I have a small web calculator which calculates time. My mobile browser gets rid of all data when I've minimised/closed the mobile broswer for a few minutes or on a page refresh so I've made a button which can reload all previous data and displays as text.</p>
  
  <p>I want to get rid of the "Get old data" button and just have the page reload with all the values displayed in the input box as they were before the page refresh.</p>
  
  <p>I've been thinking an onload event in the input box would work but as i understand this is not possible.</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;body onload="getreload()"&gt;
  &lt;p&gt;Please enter minutes&lt;/p&gt;
  &lt;input type="text" id="etime"&gt;
  &lt;br&gt;
  &lt;p&gt;Please enter time in 24 hour format (eg. 15:00)&lt;/p&gt;
  &lt;input type="text" id="stime"&gt;
  &lt;br&gt;
  
  &lt;br&gt;
  &lt;button onclick="myFunction()"&gt;Calculate&lt;/button&gt;
  &lt;p id="finishtime"&gt;
  &lt;br&gt;
  &lt;br&gt;
  &lt;button onclick="getreload()"&gt;Get old data&lt;/button&gt;
  &lt;p id="finishtime2"&gt;
  
  &lt;p id="mintime2"&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Javascript</p>
  
  <pre><code>function myFunction() {
  
  
  
  function converToMinutes(s) {
      var c = s.split(':');
      return parseInt(c[0]) * 60 + parseInt(c[1]);
  }
  
  function parseTime(s) {
      var seconds = parseInt(s) % 60;
      return Math.floor(parseInt(s) / 60) + ":" + ((seconds &lt; 10)?"0"+seconds:seconds);
  }
  
  
  var endTime = document.getElementById("etime").value; 
  var startTime = converToMinutes(document.getElementById("stime").value);
  var converted = parseTime(startTime - endTime);
  
  
  document.getElementById('finishtime').innerHTML = "You will finish your break at " + converted;
  
  if (typeof(Storage) !== "undefined") {
  localStorage.setItem("convertedTime", converted);
  localStorage.setItem("endTimeReload", endTime);
  } else {
  // Sorry! No Web Storage support
  }
  
  }
  
  
  function getreload()    {
  var convertedTime = localStorage.getItem("convertedTime");
  document.getElementById('finishtime2').innerHTML = "End of break time: " + convertedTime;
  
  
  var endTimeReload = localStorage.getItem("endTimeReload");
  document.getElementById('mintime2').innerHTML = "Minutes till next client: " + endTimeReload;
  }
  </code></pre>