I have created a small PHP App that extracts stuff from a MySQL database. Five records are selected at random for extraction and showing on screen. At the bottom of the display is a form (id = 'commentsform') with 'submit' button, which will re-run the script and display a new random selection of results. Works perfectly when I click the submit button manually.

I've written two alternative ways of doing it, which aren't relevant here. I want to see which way runs fastest. I've set up a timer on the script, which works fine, but the result of a single run is so fast I'm trying to run the script 100 times to get a better figure. So at the bottom of my script I have:
Code:
<script type='text/javascript'>
	function goAgain() {
//		var frm = document.getElementById('commentsform');
//		frm.submit();
		document.forms[0].submit();
	}
	window.onload = goAgain;
</script>
</body>
</html>
As you can see, I've tried two ways of accessing the form (one is commented out). In BOTH cases I'm getting a Javascript console error message "document.forms[0].submit is not a function" (or "frm.submit is not a function").
This approach to automatically submitting a form is widely advocated on the internet, so I can't see why it doesn't work for me. Can anyone help here, please ?

I'm aware that if it did work there is presently no way of stopping the script, but I can probably take care of that once it works. (The PHP counts to 100, but not not the JS. The easy way might be not to display the form after 100 cycles.)