Help with this

Discussion in 'JavaScript' started by krdzal, Oct 14, 2009.

  1. #1
    script type="text/javascript">
    function createTimer(t,e,g) {
    g = g || 1;
    t = Math.floor(t);
    var f = function(){
    var h = Math.floor(t/3600), m = Math.floor((t-(h*3600))/60), s = t - (h*3600) - (m*60);
    if (s < 10) {
    s = "0"+s;
    }
    e.value = h+":"+m+":"+s;
    t-=g;
    if (t < 0) {
    clearInterval(i);
    }
    };
    f();
    var i = setInterval(f,g*1000);
    }
    </script>
    <div style="float:left">
    <input type="text" id="timer">
    <script type="text/javascript">createTimer(1296000,document.getElementById("timer"))</script>


    I have that code. I know very little JS. How can a make that script so instead of printing the counter into textfileld to be printed in DIV with some ID (timer for example)
     
    krdzal, Oct 14, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    replace e.value = h+":"+m+":"+s; with: e.innerHTML = h+":"+m+":"+s;
     
    dimitar christoff, Oct 14, 2009 IP
  3. krdzal

    krdzal Peon

    Messages:
    105
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks dude :)
     
    krdzal, Oct 15, 2009 IP