restore dropdown selection after refresh local storage
<p>I am trying to save an options tag value to local storage. After saving its value to local storage I would like to be able to set the options tag to the option the user selected. I have tried the follow, but I am only able to save the value. I have trouble changing the select tag to the users selected value.</p>

<pre><code>&lt;select name="fruit" id="fruit"&gt;
    &lt;option value="1"&gt;Apple&lt;/option&gt;
    &lt;option value="2"&gt;Guava&lt;/option&gt;
    &lt;option value="3"&gt;Mango&lt;/option&gt;
    &lt;option value="4"&gt;Grapes&lt;/option&gt;
&lt;/select&gt;

document.getElementById("fruit").onchange = function() {
 localStorage.setItem('fruit', document.getElementById("fruit").value);
}

if (localStorage.getItem('fruit') === "Guava") {
 document.getElementById("fruit").setAttribute('Selected', 'Guava');
}
</code></pre>
