I'm having some trouble storing data for a click counter. Every time someone clicks on "Good" or "Bad", the number next to it will count this, but the problem is that as of yet the count gets reset to zero whenever the page is reloaded. The code is as follows:
I was wondering if anyone would be able to point me in the best direction as to how to store the data into a text file for both the good and bad count so that when a user returns to the site the count remains the same, or has grown from other users clicking as well. I'm only just getting used to AJAX and all, so any help would be greatly appreciated. Thanks!
Code:
<script>
function add_to_goodcount1(){
var goodcount1=document.getElementById('goodcount1');
var cstore = document.getElementById('good_counter_score1');
cstore.value=parseInt(cstore.value)+1;
goodcount1.innerHTML=cstore.value;
}
function add_to_badcount1(){
var badcount1=document.getElementById('badcount1');
var cstore = document.getElementById('bad_counter_score1');
cstore.value=parseInt(cstore.value)+1;
badcount1.innerHTML=cstore.value;
}
</script>
<a href="javascript:add_to_goodcount1();">Good </a><input type="hidden" name="good_counter_score1" id="good_counter_score1" value='0'><span id="goodcount1">0</span>
<p> </p>
<a href="javascript:add_to_badcount1();">Bad </a><input type="hidden" name="bad_counter_score1" id="bad_counter_score1" value='0'><span id="badcount1">0</span>
I was wondering if anyone would be able to point me in the best direction as to how to store the data into a text file for both the good and bad count so that when a user returns to the site the count remains the same, or has grown from other users clicking as well. I'm only just getting used to AJAX and all, so any help would be greatly appreciated. Thanks!