title: Save input value even if it's blank
body: <p>I <a href="https://stackoverflow.com/questions/38930144/keep-input-value-after-refresh-page">found a solution</a> that retains the value of a datatable search filter box after the page refreshes.</p>
  
  <p>What I need to do is also ensure that a blank value can be retained.</p>
  
  <p>When the user clicks the "clear button" and clears the search box, I need to set the value of the filter to blank. So when the page refreshes, the filter is blank.</p>
  
  <p>Here is the input:</p>
  
  <pre><code>&lt;input type="search" id="searchFilter" onkeyup='saveValue(this);' /&gt;
  </code></pre>
  
  <p>And here is the JavaScript:</p>
  
  <pre><code>document.getElementById("searchFilter").value = getSavedValue("searchFilter"); // set the value to this input
  
  //Save the value function - save it to localStorage as (ID, VALUE)
  function saveValue(e){
    var id = e.id;  // get the sender's id to save it . 
    var val = e.value; // get the value. 
    localStorage.setItem(id, val); // Every time user writing something, the 
    localStorage's value will override . 
  }
  
  //get the saved value function - return the value of "v" from localStorage. 
  function getSavedValue(v){
    if (!localStorage.getItem(v)) {
      return ""; // You can change this to your defualt value. 
    }
    return localStorage.getItem(v);
  }
  </code></pre>
  
  <p>Here is the clear button click event:</p>
  
  <pre><code>$('.clearFilters').on('click', function()
  {
    $('#searchFilter').val("");
    $('#example1').DataTable().search('').draw();
  });    
  </code></pre>
  
  <p>As stated, when the page is refreshed, the last value that was entered in the search is retained.  </p>
  
  <p>However, if the user clears the filter, and if the page refreshes, the last value that was entered appears again in the filter.</p>
  
  <p>The filter needs to be blank if the clear button was clicked and the page refreshes.</p>
  
  <p>I'm guessing I need to call the saveValue function from the clear button click event, but wasn't sure how.</p>