Clock Help Please

Discussion in 'JavaScript' started by domainsam, Nov 9, 2009.

  1. #1
    I am looking for a countdown timer for my site that restarts for every visitor that counts down from 10 minutes with seconds showing. What I'm looking to do is create a scrolling countdown timer that says something like "Time remaining on sale" or something similar.
    Please PM if you can help or can point me in the direction of a generator of some sort. Thanks! Will reward!
     
    domainsam, Nov 9, 2009 IP
  2. n3r0x

    n3r0x Well-Known Member

    Messages:
    257
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    120
    #2
    
    <HTML>
     <HEAD>
      <TITLE>  </TITLE>
      <script type="text/javascript">
      // Insert seconds here
        var iCount = 600;
        var sTimeleft = '';
        var iSeconds = 0;
        var iMin = 0;
        var timer;
        function Update_Timer() {
            
            iCount--;
            if(iCount >= 60) {
                iMin = Math.floor(iCount/60);
                iSeconds = iCount-(iMin*60);
            }
            sTimeleft = iMin+'m '+iSeconds+'s left on this offer';
            document.getElementById('timer').innerHTML = sTimeleft;
            timer = window.setTimeout("Update_Timer();",1000);
        }
    
      </script>
     </HEAD>
    
     <BODY onload="Update_Timer();">
      <span id="timer"></span>
     </BODY>
    </HTML>
    
    PHP:
    This should suit your needs.. :)
     
    n3r0x, Nov 9, 2009 IP
  3. domainsam

    domainsam Active Member

    Messages:
    365
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Thanks.. Does it matter where I put the code on my page? Does it need to be somewhere specific?
     
    domainsam, Nov 10, 2009 IP
  4. domainsam

    domainsam Active Member

    Messages:
    365
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #4
    I am using this right now but is there a way to make this scroll with the page on the right hand corner or something?
     
    domainsam, Nov 10, 2009 IP
  5. n3r0x

    n3r0x Well-Known Member

    Messages:
    257
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    120
    #5

    I would use Css to do that

    
    <HTML>
     <HEAD>
      <TITLE>  </TITLE>
      <style type="text/css">
        .timer { 
         position:fixed;
         top:30px;
         right:5px; 
        }
    
      </style>
      <script type="text/javascript">
      // Insert seconds here
        var iCount = 600;
        var sTimeleft = '';
        var iSeconds = 0;
        var iMin = 0;
        var timer;
        function Update_Timer() {
            
            iCount--;
            if(iCount >= 60) {
                iMin = Math.floor(iCount/60);
                iSeconds = iCount-(iMin*60);
            }
            sTimeleft = iMin+'m '+iSeconds+'s left on this offer';
            document.getElementById('timer').innerHTML = sTimeleft;
            timer = window.setTimeout("Update_Timer();",1000);
        }
    
      </script>
     </HEAD>
    
     <BODY onload="Update_Timer();">
      <span class="timer" id="timer"></span>
     </BODY>
    </HTML>
    
    
    PHP:
    What i added was:

    .timer {
    position:fixed; // Lock it in place even if page scrolls
    top:30px; // Margin from top
    right:5px; // Margin from right
    }


    and:

    <span class="timer" id="timer"></span>


    hope this is what you need/want.
     
    n3r0x, Nov 10, 2009 IP
  6. domainsam

    domainsam Active Member

    Messages:
    365
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #6
    Thanks so much for the help! I have another question.. If I wanted a pop up box for my email opt in list form and wanted it to scroll with the page how can I do this?
     
    domainsam, Nov 11, 2009 IP