Results 1 to 3 of 3

Thread: button keeps adding

  1. #1
    Join Date
    Aug 2009
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default button keeps adding

    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.


    HTML Code:
    	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);
    	}

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Can we see your HTML page too? Thanks!
    Jeremy | jfein.net

  3. #3
    Join Date
    Aug 2009
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Couple days and I figured it out. thanks

    HTML Code:
     <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>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •