/    Sign up×
Community /Pin to ProfileBookmark

constrain number of clicks

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.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@BigMoosieMay 18.2005 — 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.
Copy linkTweet thisAlerts:
@mduranauthorMay 18.2005 — 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.
Copy linkTweet thisAlerts:
@axysMay 18.2005 — Howabout something like this

[CODE]<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>[/CODE]
×

Success!

Help @mduran spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...