"Eric Petzold" <ew*******@sympatico.ca> wrote in message news:<Nm*********************@news20.bellglobal.co m>...
This is a small excerpt of a larger script, but it is creating alot of
frustration. I am trying to query the vaule of a hidden form field via
onSubmit... if the function gets called out-right it works okay, but if it
gets called onSubmit, only the first form field value gets displayed and the
rest are undefined.
Help!
<script>
function showValues() {
document.write(document.project.number.value+"<br> ");
document.write(document.project.createdOn.value+"< br>");
document.write(document.project.closedOn.value+"<b r>");
}
</script>
<form method="POST" name="project" onSubmit="showValues();">
<input type="hidden" name="number" value="2004000">
<input type="hidden" name="createdOn" value="yesterday">
<input type="hidden" name="closedOn" value="tomorrow">
<input type="submit">
</form>
<script>showValues();</script>
The use of "document.write" is always very much abused, as I see
from reading these newsgroups. As the prior gentleman said, the act of
using this, has cleared the page, and the form no longer exists.
I've been writing javascript for almost 7 years, and have yet to
have the need, in a business application, for using "document.write".
Frankly, I don't understand all these attempts to use it.
Our normal mode of operation here is to create a web page thru
html, and then to show/hide fields (using javascript) as the need
occurs. Either this, or use innerText and innerHTML properties of a
<SPAN> tag to create more dynamic pages. In any case "document.write"
has never been used a single time in thousands of lines of javascript.
And from what I see in this newsgroup, it's been a sound decision.