473,394 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Why does this fail via onSubmit, but work otherwise??

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>
Jul 23 '05 #1
2 1595
Lee
Eric Petzold said:

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>


Once the page has been completely rendered, calling document.write()
clears the current contents and begins writing a new page.
By the time the second document.write() tries to execute, your
form has been deleted.

Jul 23 '05 #2
"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.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kai Grossjohann | last post by:
I have two frames. Frame "search" contains a search form specifying an onsubmit action like so: <form ... onsubmit="foo();"> ... </form> The other frame contains a <img ......
5
by: Nige | last post by:
I've got a form which has the following code: <form action="/cgi-bin/FormMail.pl" method="POST" language="JavaScript" onsubmit="return FrontPage_Form1_Validator(this)" name="FrontPage_Form1"> ...
12
by: Frank Hauptlorenz | last post by:
Hello Out there! I have a DB2 V7.2 Database (Fix11) on Win 2000 Professional. It was before a NT 4 based Domain - now it is a Win 2000 Domain. The database server is a domain member. Now...
4
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are dynamically generated on a server, including all...
9
by: design | last post by:
Greetings, I have a situation in which an assignment operator isn't working. I'm trying to reset the value of "document.forms.f.shipping.value" to 0. I want this new value to be transmitted when...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
14
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
1
by: padew | last post by:
<form method="post" name="formWin" onSubmit="check();"> this work only if I send the form's datas directly with <input type=submit ...> if I use document.formWin.submit(); for to send the...
8
by: Mark Livingstone | last post by:
I have a form that uses the following: onSubmit="some_var = 'validated';" FireFox is OK with that. Internet Explorer isn't. any ideas why? Thanks.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.