PDA

View Full Version : Can you help me whit a count script?


Nike
04-21-2003, 01:21 PM
I need a script that counts 1++ on every time that you click on a link. And when the counter have reatched 10 a window will pop up. And when you close the window the counter will return to 0.

Please help me whit this script!

dbKnight
04-21-2003, 03:28 PM
This is fairly simple if you just want a simple built-in alert.

var nNumClick = 0;
function handleLinkClick(){
nNumClick++;
if (nNumClick>10) {
alert('This link has been clicked on 10 times already!');
nNumClick = 0;
}
}
:
:
Then, your link would have an additional attribute to handle the click event:
<a href="destination.html" onClick="handleLinkClick()">CLICK-N-COUNT-LINK</a>

* If you want a fancier display of the message, you may want to explore the use of the modal dialog.