Use CF and JavaScript. Create the cookie initially with CF.
Update the cookie when user clicks with JavaScript. Read the
updated cookie on every page load with CF using your
APPLICATION.CFM file. Write the value to a DB, etc. Copy the below
and run. Should be what you need. You might need more error
checking, I concentrated on functionality. The onLoad() in the BODY
tag initializes the JavaScript input box counter and is not
required. If not needed, remove the onLoad() call, the
initializeKounter() function and one line from updateCookie()
(which is commented).
You owe me a beer
<cfparam name="COOKIE.ANCHOR_KOUNTER" default="0">
<cfoutput>
CF anchor cookie count: #cookie.anchor_kounter#<br>
</cfoutput>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript">
function updateCookie() {
var name = 'ANCHOR_KOUNTER';
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
var new_kount = unescape(dc.substring(begin + prefix.length,
end)) - 0 + 1;
document.cookie = "ANCHOR_KOUNTER="+new_kount;
window.document.myform.kount.value=new_kount; //take out
this line if you delete the <form>
}
function initializeKounter() {
var name = 'ANCHOR_KOUNTER';
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
var curr_kount = unescape(dc.substring(begin +
prefix.length, end));
window.document.myform.kount.value=curr_kount;
}
</script>
</head>
<body onload="initializeKounter();">
<form name="myform">
javascript cookie count: <input type="text" name="kount"
size="5">
</form>
<a href="##boo" onclick="updateCookie()">click to goto
anchor</a>
<table height=200>
<tr>
<td>words
</td>
</tr>
</table>
<a name="##boo">anchor</a>
</body>
</html>