I just started learning javascript today, the main question I have is how to keep a variable stored in your website for later use, as in it does not reset. I thought a good learning example would be to try to make a reputation variable, that stores this variable somehow in the ftp? heres my code so far:
I'm trying to find a way to store that 'rep' variable without it reseting when a user visits. I also am trying to have it so a user can only vote once per visit, but that can be handled later.
Code:
<html>
<head>
<script type="text/javascript">
function disp_alert()
{
var username
username = "Andyoyo"
rep = rep + 1
alert(username + "'s Reputation Increased!" + '\n' + username + "'s total Reputation: " + rep);
}
</script>
</head>
<body>
<input type="button" onclick="disp_alert()" value="Add to this user's reputation" />
</body>
</html>
<html>
<head>
<script type="text/javascript">
function disp_confirm()
{
var r=confirm("New User?");
if (r==true)
{
document.write("Reset Reputation");
}
else
{
document.write("Reputation value contained.");
}
}
</script>
</head>
<body>
<input type="button" onclick="disp_confirm()" value="Display a confirm box" />
</body>
</html>
//UserReputation.js
if (rep == 0)
function disp_alert()
{
var username
username = "Andyoyo"
var rep
rep = 0
alert(username + "'s Reputation Increased!" + '\n' + username + "'s total Reputation: " + rep);
}
else
</script>
</head>
<body>
<input type="button" onclick="disp_alert()" value="Add to this user's reputation" />
I'm trying to find a way to store that 'rep' variable without it reseting when a user visits. I also am trying to have it so a user can only vote once per visit, but that can be handled later.