Click to See Complete Forum and Search --> : constrain number of clicks
mduran
05-18-2005, 04:57 AM
Hi,
I am building a page for listening tests. I would like to give the test subjects the possibility to listen to every wav file a limited number of times (say 3). Then I would like to hide the link to the wav file.
How can I do this ?
Much appreciated.
BigMoosie
05-18-2005, 05:07 AM
When they listen to the file it has already downloaded to the users computer so most browsers will be able to click forward or whatever to get back to it. I suggest you use flash to create this.
mduran
05-18-2005, 07:50 AM
Yeah I know. What I want is to hide the link to the wav after x number of times, which will make their life a bit more difficult if they want to listen again.
Howabout something like this
<script>
var clicks1 = 0;
var clicks2 = 0;
var clicks3 = 0;
function countClicks(number) {
//Open link to Wav sound using window.open here
// if number = 1 then open link 1 etc.
eval("clicks" + number + " = clicks" + number + " + 1;");
if (eval("clicks" + number + ";") > 2 )
{
eval("link"+ number + ".style.display = 'none';");
}
}
</script>
<a id=link1 href="javascript:void(0)" onclick="countClicks(1);">Link 1</a>
<br>
<a id=link2 href="javascript:void(0)" onclick="countClicks(2);">Link 2</a>
<br>
<a id=link3 href="javascript:void(0)" onclick="countClicks(3);">Link 3</a>