forevergone
11-08-2006, 02:02 AM
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?
//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?