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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Heading Confusion...

    Hi guys, I've had some problems with a script I've been toying around with. I'm new with javascript so I started to fool around with inputs and outputs with functions. One problem I've come across is this: when I have a function thats only designated with outputs, it appears first before the output title I've created. Here's the code:

    //Simple function to output the results into a table
    function GameResult()
    {
    var top = 0
    output("<table border='1'>")
    output("<tr><td>" + away + "</td><td>" + awaypoints + "</td></tr>")
    output("<tr><td>" + home + "</td><td>" + homepoints + "</td></tr>")
    output("</table><br>")
    return top
    }

    ...

    //INPUT
    date = inputString("What is the date that the game was played on? (MM/DD/YY)")
    games = inputNum("How many games were played on that day?")
    for (; {
    if(games >= i == false) break
    home = inputString("Enter the name: ")
    homepoints = inputNum("Enter the score of the home team: ", 0)
    away = inputString("Enter the name of the away team: ")
    awaypoints = inputNum("Enter the score of the away team: ", 0)
    i = i + 1
    }

    //PROCESSING
    results = GameResult()

    //OUTPUT
    output("<h1>Results for: " + date + "</h1>")
    output(results)

    </script>
    </body>
    </html>

    I was just curious as to why it comes up first, and what are some solutions I could do to fix this?

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    where is the rest of your script? you call to other function but you do not have them included in your post.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry about that, this is the full script:

    <html>
    <head>
    <title>Test Program</title>

    <script language="javascript">

    //Simple function to output the results of a game in a simple table
    function GameResult()
    {
    var top = 0
    output("<table border='1'>")
    output("<tr><td>" + away + "</td><td>" + awaypoints + "</td></tr>")
    output("<tr><td>" + home + "</td><td>" + homepoints + "</td></tr>")
    output("</table><br>")
    return top
    }

    </script>
    </head>
    <body>

    <script language="javascript">

    //PLACE YOUR PROGRAM HERE
    var date
    var games
    var i = 1
    var results
    var home, homepoints, away, awaypoints

    //INPUT
    date = inputString("What is the date that the game was played on? (MM/DD/YY)")
    games = inputNum("How many games were played on that day?")
    for (; {
    if(games >= i == false) break
    home = inputString("Enter the name of the home team: ")
    homepoints = inputNum("Enter the score of the home team: ", 0)
    away = inputString("Enter the name of the away team: ")
    awaypoints = inputNum("Enter the score of the away team: ", 0)
    i = i + 1
    }

    //PROCESSING
    results = GameResult()

    //OUTPUT
    output("<h1>Basketball Results for: " + date + "</h1>")
    output(results)

    </script>
    </body>
    </html>

    @brandonH: I only call on one function in this program, and thats the table values. I just cant figure out why the table comes up. I cant think of a reason as to why it does this.

  • #4
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    what about the calls such as :

    inputString()
    output()
    inputNum()

    those are calls to functions, wether or not they are defines by you does not matter. is this a client side or server side script?
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.


  •  

    Posting Permissions

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