I have been working on the script below for a while now and I am stuck. I have tried to see what is wrong and I think it is something small.
<form name="f1">Gold:
<input type="text" value='0' name="t1" id="a2" disabled>
<br>
<input type="button" value="Click me!" id="a1" onclick="clickAdd">
<br>Jewels:
<input type="text" value="0" name="g1" id="a3" disabled>
<br>Cost: 50 Gold
<input type="button" value="5 jewels" id="a4" onclick="click5()">
<br>Cost: 100 Gold
<input type="button" value="10 jewels" id="a5" onclick="click10()">
<br>
</form>
<script>
function clickAdd() {
//Detects if local stoage click count exists
if (localStorage.getItem("clickcount") == null || NaN) {
localStorage.setItem(clickcount, 0);
document.getElementById("a2").value = localStorage.getItem('clickcount');
//Sets the clickcount to zero
}
else {
//If it already exists.
localStorage.setItem("clickcount",localStorage.clickcount + 1);
document.getElementById("a2").value = localStorage.getItem('clickcount');
}
}
</script>
Can someone please fix it or tell me what is wrong.