Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2006
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple variables

    I have dumbed this down quite alot but the basic principle of my problem is still there.

    Code:
    <script>
     function tournypoints()
     {
    var tp = 200 - 100;
    document.getElementById("tp2").innerHTML=tp
     }
    </script>
    <body>
    <div id="tp2"></div>
    </body>
    I want the reuslt of 200-100 to appear in the body in between the div tags, although this does not happen.

    Can someone tell me what i have missed or an alternative/better way of doing this.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You are not calling tournypoints() onload.
    Code:
    <body onload="tournypoints()">
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Jun 2006
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <body onload="opener.autosize(window)"> i already have that code in the body tags.. how do i add <body onload="tournypoints()"> also?

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Separate them with semicolon.
    Code:
    <body onload="opener.autosize(window); tournypoints()">
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New Coder
    Join Date
    Jun 2006
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you very much

    how do you round numbers?
    Last edited by HIPPY; 06-11-2007 at 05:22 PM.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    Math.round(theNumber)
    More info here.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •