Selective Click

The following script allows you to use a single link to run a choice of functions.
The example script is set up to run either one of two functions on a simulated "onclick" or "ondblclick"

First do a single click, then a double click, then click three times. Click Here

     

Everytime the link is clicked the value of variable Count is increased by one which in turn determines which function to run.
The response time of the link is controlled by the setTimeout method and may have to be lengthened depending on the total number of clicks.

<script type="text/javascript">
<!--
//jeff
//www.huntingground.freeserve.co.uk

Count=0
timer=""
function Set_Count(){
clearTimeout(timer)
Count++ // increase Count value by 1
timer=setTimeout("Check_Count()",300)
}

function Check_Count(){
if(Count==1){
click1()
}
if(Count==2){
click2()
}
if(Count==3){
click3()
}
Count=0 // reset Count value
}

function click1(){
alert("This was a single click")
}

function click2(){
alert("This was a double click")
}

function click3(){
alert("This was a triple click")
}
// -->
</script>

<a href="#null" onmouseup="Set_Count()">Example Link</a>

Additions can be made to allow a function to be run on a third click or more by replacing the function "Check_Count" for the following, adding more if statements as required.

function Check_Count(){
if(Count==1){
click1() // run function on one click
//alert("This was a single click")
}
if(Count==2){
click2() // run function on two clicks
//alert("This was a double click")
}
if(Count==3){
//click3() // run function on three clicks
alert("This was a triple click")
}
Count=0
}

Then just add your third function.

function click3(){
alert("This was a triple click")
}