Page 1 of 4 123 ... LastLast
Results 1 to 10 of 39

Thread: Need Help With Coding

  1. #1
    Premium Member theZcuber's Avatar
    Join Date
    May 2011
    Location
    Central NY, US
    WCA Profile
    2012PRAT02
    Posts
    1,792

    Default Need Help With Coding

    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 by theZcuber; 12-05-2011 at 04:13 PM.
    RPG (CFOP and Roux) - CubingStats
    WCA - CubingUSA - canadianCUBING - UKCA
    RPG and CubingStats can be useful, try them out!

  2. #2
    Colourful Kirjava's Avatar
    Join Date
    Mar 2006
    WCA Profile
    2006BARL01
    YouTube
    snkenjoi
    Posts
    5,248

    Default

    You left some <div> tags open before <div id="fw-sidebar"> and need to close them.

    my paypal address is snkenjoi@gmail.com

    np

  3. #3
    Premium Member theZcuber's Avatar
    Join Date
    May 2011
    Location
    Central NY, US
    WCA Profile
    2012PRAT02
    Posts
    1,792

    Default

    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 by theZcuber; 08-24-2011 at 07:36 AM.
    RPG (CFOP and Roux) - CubingStats
    WCA - CubingUSA - canadianCUBING - UKCA
    RPG and CubingStats can be useful, try them out!

  4. #4
    Colourful Kirjava's Avatar
    Join Date
    Mar 2006
    WCA Profile
    2006BARL01
    YouTube
    snkenjoi
    Posts
    5,248

    Default

    After <div class="fw-paragraphbottom">.

  5. #5
    Premium Member theZcuber's Avatar
    Join Date
    May 2011
    Location
    Central NY, US
    WCA Profile
    2012PRAT02
    Posts
    1,792

    Default

    Hmm...weird

    Now to try and figure out how to get that inserted (and how a </div> got removed)
    RPG (CFOP and Roux) - CubingStats
    WCA - CubingUSA - canadianCUBING - UKCA
    RPG and CubingStats can be useful, try them out!

  6. #6
    Premium Member theZcuber's Avatar
    Join Date
    May 2011
    Location
    Central NY, US
    WCA Profile
    2012PRAT02
    Posts
    1,792

    Default

    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
    RPG (CFOP and Roux) - CubingStats
    WCA - CubingUSA - canadianCUBING - UKCA
    RPG and CubingStats can be useful, try them out!

  7. #7
    Colourful Kirjava's Avatar
    Join Date
    Mar 2006
    WCA Profile
    2006BARL01
    YouTube
    snkenjoi
    Posts
    5,248

    Default

    Eh, I had it working fine before.

    I'll send you a fixed copy when I get home.

  8. #8
    Premium Member theZcuber's Avatar
    Join Date
    May 2011
    Location
    Central NY, US
    WCA Profile
    2012PRAT02
    Posts
    1,792

    Default

    Alright. After I receive the fixed copy (and hopefully how to insert it with webs) I'll send you the $5
    RPG (CFOP and Roux) - CubingStats
    WCA - CubingUSA - canadianCUBING - UKCA
    RPG and CubingStats can be useful, try them out!

  9. #9

  10. #10
    Premium Member theZcuber's Avatar
    Join Date
    May 2011
    Location
    Central NY, US
    WCA Profile
    2012PRAT02
    Posts
    1,792

    Default

    Lol talk about broken code
    RPG (CFOP and Roux) - CubingStats
    WCA - CubingUSA - canadianCUBING - UKCA
    RPG and CubingStats can be useful, try them out!

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
  •