[Javascript] Changing INPUT values in forms after submit is p ushed

Muchacho, Laurent (TWIi London) LMuchacho at twii.net
Fri Aug 1 05:04:13 CDT 2003


Hi Rick 
 
You problem sound pretty simple I guess  that you on only trying to change
the value in your input once you clicked the submit button and let the
document submitting.
What's happen is when you click on the submit the page will automaticly
gather the info of your form and start to send it to the recipient page and
your javascript to populate the input occur after this that why your CGI get
null for the input field 
 
What you should do is 
1: on the form tag have something like this <form name="whatever"
onsubmit="return doSomething()">
 
function doSomething(){
//    your code to change the input value go here and after return true 
 
return true   
//if you want the form to stop being submitted return false 
}
 
or second solution 
2: replace the input type submit by a input type button 
<input type="button" name="myButtonSimulateSubmit" value="Submit"
onclick="doSomething()">
 
function doSomething(){
//    your code to change the input value go here and after submit the form 
 
document.formName.submit()
 
 
//if you want the form to stop being submitted don't call the
document.formName.submit()
}
 
PS: One really important things with point 2 is that you must make sure that
no element button input type or nothing else is name submit or this will
cause an error 
 
 
 

-----Original Message-----
From: Rick Warren [mailto:webmaster at bizmaxsoftware.com]
Sent: 01 August 2003 04:45
To: javascript at LaTech.edu
Subject: [Javascript] Changing INPUT values in forms after submit is pushed


I have a form that uses an onsubmit to validate the data and calculate
options selected in the form.  I need to pass the calculated value back to
an INPUT tag's value to be sent to a CGI script.  I use something similar to
f.tag.value = calc_value where calc_value is the calculated value my
validation/ calculation script generates.  When the data makes it over to my
cgi program, the tag value is null. What's wrong??? 



DISCLAIMER - The preceding e-mail message (including any attachments)
contains information that may be confidential, may be protected by the
attorney-client or other applicable privileges, or may constitute non-public
information.  It is intended to be conveyed only to the designated
recipient(s) named above.  If you are not an intended recipient of this
message, or have otherwise received it in error, please notify the sender by
replying to this message and then delete all copies of it from your computer
system.  Any use, dissemination, distribution, or reproduction of this
message by unintended recipients is not authorized and may be unlawful. The
contents of this communication do not necessarily represent the views of
this company.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20030801/ef5db113/attachment.htm>


More information about the Javascript mailing list