...

View Full Version : Heading Confusion...



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?

brandonH
11-08-2006, 02:15 AM
where is the rest of your script? you call to other function but you do not have them included in your post.

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

brandonH
11-08-2006, 10:06 PM
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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum