• Welcome to the Speedsolving.com, home of the web's largest puzzle community!
    You are currently viewing our forum as a guest which gives you limited access to join discussions and access our other features.

    Registration is fast, simple and absolutely free so please, join our community of 40,000+ people from around the world today!

    If you are already a member, simply login to hide this message and begin participating in the community!

Need Help With Coding

cubernya

Premium Member
Joined
May 8, 2011
Messages
2,076
Location
Central NY, US
Alright, I'm back again, and need some more help. This time I'm trying to code a very simple timer, not even a cubing timer (although I might make it one). I can't seem to get the timer to stop at all.

Source code:
Code:
<script type='text/javascript'>
function start(){
	window.int = setInterval('timer()',10);
	document.getElementById('startstop').onkeydown = 'stop()';
	document.getElementById('startstop').value = 'STOP';
}
function stop(){
	int = clearInterval(int);
	document.getElementById('startstop').onkeydown = 'start()';
	document.getElementById('startstop').value = 'START';
	var t = document.getElementById('times').innerHTML;
	var ct = document.getElementById('sec').innerHTML + document.getElementById('frac').innerHTML;
	document.getElementById('times').innerHTML = t + ' ,' + ct;
}
function timer(){
	// Define variables
	var frac = Math.round(document.getElementById('frac').innerHTML);
	var sec = Math.round(document.getElementById('sec').innerHTML);
	
	// Change decimal and second
	frac = frac + 1;
	if(frac <= 9){
		frac = '0' + frac;
	}
	else if(frac == 100){
		frac = '00';
		sec = sec + 1;
	}

	// Change time displayed
	document.getElementById('frac').innerHTML = frac;
	document.getElementById('sec').innerHTML = sec;
}
</script>

<table width='1000' height='450'><tr>
<td valign='middle' align='center'>

<font size='7'><span id='time' onkeyup='start()'><span id='sec'>0</span>.<span id='frac'>00</span></span></font>
<br/>
<input type='text' value='START' onkeydown='start()' maxlength='0' size='12' id='startstop'/>
<br/><br/>
<span id='times'></span>
</td>
</tr></table>

As you can see, under stop(), I put the clear.interval. I've tried putting in window.clear.interval and/or window.int = ... but none have worked. I was just wondering how I should go about getting it to stop in Firefox. This is actually for a project, and I need a timer to show in the corner, but don't want something larger like qqTimer.
 
Last edited:

cubernya

Premium Member
Joined
May 8, 2011
Messages
2,076
Location
Central NY, US
Could you show me where I would need to insert the </div>? It might be in a sidebar module I took from PayPal's code...

EDIT: I see where you mean to insert it. Just at the end of the second view cart button, correct?
 
Last edited:

cubernya

Premium Member
Joined
May 8, 2011
Messages
2,076
Location
Central NY, US
Just did a non-live version of the webpage by inserting it (anywhere from 1-3 </div>s) and all it did was add in the background colour for the sidebar, but nothing else
 

cubernya

Premium Member
Joined
May 8, 2011
Messages
2,076
Location
Central NY, US
So now the question remains...was this my coding fault or was it the site I'm using?

(and how to insert the </div> tags without replacing everything)
 

cubernya

Premium Member
Joined
May 8, 2011
Messages
2,076
Location
Central NY, US
Yeah it's no where near like that when I'm editing it :p Anything I code is nice and organized

That's just what the site puts up
 
Top