I'm trying to store a textbox value to local storage however I'm catching an Uncaught TypeError: Cannot set property 'onclick' of null and not sure exactly why. Everything seems to be referenced correctly. Any insight would be appreciated.
<script type="text/javascript">
var save_button = document.getElementById('Save')
save_button.onclick = saveData;
function saveData()
{
var input = document.getElementById("saveServer");
localStorage.setItem("server", input.value);
var storedValue = localStorage.getItem("server");
};
</script>
<label for="serveri">Server:</label>
<input type='text' name="server" id="saveServer" />
<button onclick="saveData()" type="button" value="Save" id="Save">Save</button>
If the above doesn't show my problem, here is the whole in JSFiddle: http://jsfiddle.net/mGfeu/