Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hit counter

Status
Not open for further replies.

nnn000555

Programmer
Jan 30, 2011
26
CA
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?
 
Hi

You are aware that the counter will have different values in each browser, right ?
Code:
[b]<input[/b] [maroon]type[/maroon][teal]=[/teal][green][i]"button"[/i][/green] [maroon]onclick[/maroon][teal]=[/teal][green][i]"setcookie('foo',parseInt('0'+getcookie('foo'),10)+1)"[/i][/green][b]>[/b]
The setcookie() / getcookie() are not standard functions, search the web for suitable implementations.

Feherke.
 
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>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top