473,802 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.projec t.number.value+ "<br>");
document.write( document.projec t.createdOn.val ue+"<br>");
document.write( document.projec t.closedOn.valu e+"<br>");
}
</script>

<form method="POST" name="project" onSubmit="showV alues();">
<input type="hidden" name="number" value="2004000" >
<input type="hidden" name="createdOn " value="yesterda y">
<input type="hidden" name="closedOn" value="tomorrow ">

<input type="submit">
</form>

<script>showVal ues();</script>
Jul 23 '05 #1
2 1615
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.projec t.number.value+ "<br>");
document.write( document.projec t.createdOn.val ue+"<br>");
document.write( document.projec t.closedOn.valu e+"<br>");
}
</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*******@symp atico.ca> wrote in message news:<Nm******* **************@ news20.bellglob al.com>...
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.projec t.number.value+ "<br>");
document.write( document.projec t.createdOn.val ue+"<br>");
document.write( document.projec t.closedOn.valu e+"<br>");
}
</script>

<form method="POST" name="project" onSubmit="showV alues();">
<input type="hidden" name="number" value="2004000" >
<input type="hidden" name="createdOn " value="yesterda y">
<input type="hidden" name="closedOn" value="tomorrow ">

<input type="submit">
</form>

<script>showVal ues();</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
2735
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 ... onclick="perform_search();"> where the perform_search function is defined as follows:
5
5705
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"> It works, but I don't understand it. If I try and use this code on another site it fails (Error: Object expected), but works with:
12
2954
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 sometimes Win 2000 Clients can't connect to the database. They connect over TCP/IP. The db2log says that the function getHostByName failed. It seems to be only on new installed win 2000 Workstations. Already installed WS have NOT this problem.
4
10151
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 the validators. The user enters the data, presses OK. My OK button is dynamically generated as well, with some code-behind logic in
9
1500
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 the form is submitted. Unfortunately, the form's shipping element's value remains set at "19.00." I have looked for an answer in "JavaScript: the Definitive Guide 4th edition" and in the clj FAQ. I also reviewd clj posts dating back to
9
2156
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 should work. Also the second nav.OuterXml appears to also be wrong to me. Can someone explain to me why this does not work? (This is an example from a program we have where xpath can be entered in two parts so we have to be able
14
4865
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 can be done using the designer but I intentionally don't want to use that. The one reason is that you cannot change the code generated by the designer. The other could be that you have more free hand and control to design your GUI. 2....
1
1415
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 datas onSubmit="check() not work more; is there any solution?
8
6853
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
10538
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.