Al said:
Could I get you to take a look at
www.brendasfire.com/amej/darvan.html
andoffer suggestions before I jump off into something I can't crawl out of.
1. *Always* specify units - 800 m, 400 m, etc.
2. The abbreviation for centimetre is cm, not CM. Incidentally, cm is
not an official unit of measure, but metre (m) is - but that is way
to picky for your application.
If you intend the results to be sent to some official sports body,
consider making all measurements metres (at least seek the opinion
of a few reputable organisations for their opinion).
3. If there is a choice of only two values (yes/no, on/off), use a
checkbox:
<label for="hurdles400">400 m Hurdles: <input
type="checkbox" name="hurdles400" id="hurdles400"></label>
4. If your validation fails, you should return false to stop the form
from submitting:
<form ... onsubmit="return validForm(this);">
and in the function validForm():
return intHasError;
In some browsers, onsubmit returns the value of the function that it
called (i.e. relays validForm's 'false' to the form), but some
don't. Even if the function returns "false", the actual onsubmit
has been successful and so it can be argued that it should return
success (or true) even if the function returned false - unless it is
programmed explicitly to forward the returned value.
This makes sense, so you can test if the function itself worked or
not. That is, onsubmit succeeded but returned false. But it isn't
how the majority of browsers actually work (as far as I know).
5. Don't use language in your script tag, just use type:
<script type="text/javascript">
6. In your script, you have 11 document.write calls. Using an array
and join() is much more efficient:
var docContent = [
'<html><head><title>Darvans Track Program</title>',
'<style type="text/css">',
'.letterhead {text-align: center;',
' text-decoration: "bold";}',
'</style>',
'</head><body>',
'<p class="letterhead">James Darvan</p>',
'<p class="letterhead">we live somewhere</p>',
'<p class="letterhead">in some city</p><br />',
'<p>Date: frmThis.completiondate.value</p><br>',
'<p>in some city</p><br />',
'<p onclick="self.close()" style="color: blue;',
' text-decoration: underline;">Close</p>',
'</body></html>'
];
generator.document.write(docContent.join(''));
generator.document.close()
7. Don't use <a href="javascript:... > Try this:
<p onclick="self.close()" style="color: blue;
text-decoration: underline;">Close</p>
8. There are also much more efficient ways of going through your form
elements to validate the content, but I'll leave that for later.
My $0.02 worth.