1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. To chat with the GameOgre community, you need to have at least 100 posts. Once you have the 100 posts, post at Become A New Ogre
    Dismiss Notice

javascript countdown problem

Discussion in 'Online Game Development' started by rtkwar, Nov 23, 2011.

Thread Status:
Not open for further replies.
  1. rtkwar

    rtkwar Big Brute New Ogre

    Messages:
    142
    Likes Received:
    1
    Trophy Points:
    18
    Credit:
    298.66
    hi iwill make game like travian and tribalwars in this games if you want build soldier you will need 5:09:59 hours how ican make count down for this
    thats my code but not work,why?



    <script type="text/javascript">
    function timer(date){
    var time=date.split(":");
    if(time[0]>0){
    time[0]=time[0]-1;
    t=settimeout("timer('5:09:59')",1000);
    document.getElementById("test").innerHTML=time[0];
    }else{}
    }
    </script>
    <b id=test></b>
    <input type=submit onclick="timer('5:09:59')">






     
  2. shugo

    shugo Elite Ogre Ogre Veteran

    Messages:
    2,093
    Likes Received:
    12
    Trophy Points:
    38
    Credit:
    15,378.42
    not sure what exactly you're trying to do here, could you elaborate more?

    have you considered this?

    what happens if the user closes the page?!

    remember javascript is clientside, not serverside


    and if it did work, you would still have to reload the page, when it reaches 0 seconds

    like for example: window.location.assign("roma.php")


    i'm not too familiar with countdowns in javascript, because I've never used it myself, you may have better luck asking this in a javascript help forum
     
  3. rtkwar

    rtkwar Big Brute New Ogre

    Messages:
    142
    Likes Received:
    1
    Trophy Points:
    18
    Credit:
    298.66
    you can tell me good forums for my questions?
     
  4. shugo

    shugo Elite Ogre Ogre Veteran

    Messages:
    2,093
    Likes Received:
    12
    Trophy Points:
    38
    Credit:
    15,378.42
    hmm that's a tough one, I don't visit many javascript help forums these days.

    You could try phpfreaks, though they're more about php, they do have a javascript subforum
     
  5. Admin Post
    ogreman

    ogreman Ogre In Charge Staff Member GameOgre Admin

    Messages:
    52,022
    Likes Received:
    8,869
    Trophy Points:
    113
    Credit:
    461,126.20
    Have you tried a Javascript book? I recently bought an old one to help whenever I had a problem with Javascript.
     
  6. shugo

    shugo Elite Ogre Ogre Veteran

    Messages:
    2,093
    Likes Received:
    12
    Trophy Points:
    38
    Credit:
    15,378.42
    good suggestion that ^

    if you need a cheap book, i have a copy of the javascript bible in pdf format. I could upload it to my site and then you can download the book from there.
     
  7. Admin Post
    ogreman

    ogreman Ogre In Charge Staff Member GameOgre Admin

    Messages:
    52,022
    Likes Received:
    8,869
    Trophy Points:
    113
    Credit:
    461,126.20
    Javascript books hold their usefulness more than other languages etc right?
     
  8. shugo

    shugo Elite Ogre Ogre Veteran

    Messages:
    2,093
    Likes Received:
    12
    Trophy Points:
    38
    Credit:
    15,378.42
    that they do
     
  9. hypokill

    hypokill Club Swinger New Ogre

    Messages:
    61
    Likes Received:
    0
    Trophy Points:
    6
    Credit:
    30.00
    Also wanted to add.... Javascript is loaded on the clients pc. Not the server. What you will want is php. If you want the time to show in realtime then you will want to use javascript in conjuction. Hope this helps.
     
  10. oraklus

    oraklus Ogre Newling

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Credit:
    0.00
    Php will always return the current remaining time to the browser. And whenever a time is returned to the browser, javascript will start countdown. So, javascript is a stupid machine in this example. Php does everything.
     
Thread Status:
Not open for further replies.

Share This Page