1. ## Stumped..

I'm currently working on a personal website, as a means of learning html/javascript. I'm trying to develop a 'simple' mathematical function that deals with calculations of knocked over cones for autocrossing, and cannot seem to figure out where I'm going wrong.

I've stumbled upon this site and was wondering if you all would be willing to help me out.
I'll attach the code in question below, hopefully you all will be able to help

Section in the webpage where the function is called.
Code:
```<form name ="Cone" onload="ConeCalculator(this.form)" id="page_content" style="width: 320px">
</form>```
The javascript file is loaded up in the script section through
Code:
`<script type="text/javascript" src="media/javascript/ConeCalculator.js">`

Here is the code inside the javascript file. The idea in mind is to randomly generate a number (minutes.seconds) as well as a random number of cones that have been knocked over. The objective of the user is t o correctly add up the correct time for the amount of cones knocked over. I've yet to get to adding in the input object for the user, because i cannot get the random numbers to display at all. Here is the current code i've created
Code:
```function ConeCalculator(Cone)
{

var Minutes;
var Seconds;
var Cones;

document.writeln("<table border =\"0\">");
document.writeln("<caption>Cone Calculations</caption></tr>");

for (var i = 0; i <= 1; i++)
{
Minutes = Math.floor( 1 + math.random() * 10);
Seconds = Math.floor( 1 + Math.random() * 60);
document.writeln("<td>" + "Your car finished in " + Minutes + "." + Seconds + "." + "</td></tr>");
Cones = Math.floor( 1 + math.random() * 20);
document.writeln("<td><tr>" + "Cones knocked over" + Cones + "</td></tr>");
}

}```
The idea here is to have all of this generated in a function, then inserted into the form created on the page. None of the javascript debuggers I know of seem to help (firebug, i.e debugger and chrome's debugger). No errors are being logged, yet nothing happens when the page loads. I've attempted adding a button to trigger the function but to no avail. Any help would be greatly appreciated!

2. Your function contains document.writeln which can only run before the page finishes loading but the function is only called after the page finishes loading.

3. Originally Posted by felgall
Your function contains document.writeln which can only run before the page finishes loading but the function is only called after the page finishes loading.
That's not correct. I've used document.write and document.writeln after a page finishes loading and the output is written to a new page as it is supposed to.

#### Posting Permissions

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