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 15 posts. Once you have the 15 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 Member

    Messages:
    139
    Likes Received:
    0
    Trophy Points:
    16
    Credit:
    - 54.14
    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 Active Member Ogre Veteran

    Messages:
    2,092
    Likes Received:
    10
    Trophy Points:
    38
    Credit:
    14,301.21
    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 Member

    Messages:
    139
    Likes Received:
    0
    Trophy Points:
    16
    Credit:
    - 54.14
    you can tell me good forums for my questions?
     
  4. shugo

    shugo Active Member Ogre Veteran

    Messages:
    2,092
    Likes Received:
    10
    Trophy Points:
    38
    Credit:
    14,301.21
    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:
    37,587
    Likes Received:
    7,090
    Trophy Points:
    113
    Credit:
    5,210.65
    Have you tried a Javascript book? I recently bought an old one to help whenever I had a problem with Javascript.
     
  6. shugo

    shugo Active Member Ogre Veteran

    Messages:
    2,092
    Likes Received:
    10
    Trophy Points:
    38
    Credit:
    14,301.21
    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:
    37,587
    Likes Received:
    7,090
    Trophy Points:
    113
    Credit:
    5,210.65
    Javascript books hold their usefulness more than other languages etc right?
     
  8. shugo

    shugo Active Member Ogre Veteran

    Messages:
    2,092
    Likes Received:
    10
    Trophy Points:
    38
    Credit:
    14,301.21
    that they do
     
  9. hypokill

    hypokill New Ogre 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 New Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Credit:
    - 20.57
    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