PDA

View Full Version : button keeps adding



zbphill
02-16-2010, 08:03 PM
If you click the start button twice it multiples the time. So what I want is if you click start it deactivates it until you click the stop button.



var frame=0
function start(){
document.getElementById("timer").innerHTML = frame;
go=setTimeout("start()",300)
frame++
S7Config.setFlashParam('_frameButton1','currentFrame', frame);
if(frame==36){
frame=0
}
}

function stop(){
clearTimeout(go)
}
function resetBtn(){
frame=0
S7Config.setFlashParam('_frameButton1','currentFrame', frame);
}

Nile
02-16-2010, 11:45 PM
Can we see your HTML page too? Thanks!

zbphill
02-18-2010, 04:06 PM
Couple days and I figured it out. thanks



<style>
span{
cursor:pointer;
color:white;
background:black;
}
</style>

<script type="text/javascript">
var frame=0;
var t;
var timer_is_on=0;
var x=1;
document.getElementById("timer").innerHTML = frame;

function timedCount(){
S7Config.setFlashParam('_frameButton1','currentFrame', frame);
frame++;
t=setTimeout("timedCount()",350);
document.getElementById("timer").innerHTML = frame;
if(frame==36){
frame=0;
}
}

function doTimer(){
if (!timer_is_on){
timer_is_on=1;
timedCount();
}
}

function stopCount(){
clearTimeout(t);
timer_is_on=0;
}
function resetBtn(){
frame=0
S7Config.setFlashParam('_frameButton1','currentFrame', frame);
timer_is_on=0
document.getElementById("timer").innerHTML = frame;
}

</script>
<span id="over1" onClick="doTimer()">Start</span>
<span id="over2" onClick="stopCount()">Stop</span>
<span id="over3" onClick="resetBtn()">Reset</span>
<div id="timer"></div>