How do you create a counter on the web page using a button, as you press the button, the counter goes up by one, and allow it to stay after the web page is refreshed? Something like a hit counter?
I have found a way to do the counter. Thanks. Here is the sample code.
<html>
<head>
</head>
<body>
<script type="text/javascript">
var c=0;
var file = "\\my-path.txt"
function addToFile() {
var fs = new ActiveXObject("Scripting.FileSystemObject")
var ts = fs.OpenTextFile(file,8,true,-2)
/*
var t = document.getElementById("txt").value
*/
alert("Saving... ")
c++;
ts.WriteBlankLines(3) ;
// Write a line.
ts.Write(c);
ts.Close()
ts=fs=null
}
</script>
<form action="" name = "frm">
Click here:
<!--
<textarea id="txt" rows="5" cols="5"></textarea>
-->
<input type="button" onclick="addToFile()" value="Save Information To Submit" />
</form>
</body>
</html>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.