Re: How do I do post form submission processing?

>From: "Amit Rekhi" <amit@abinfosys.com>

>To: "HTML LIST" <www-html@w3.org>

>Date: Fri, 7 Aug 1998 12:11:59 +0530

>Subject: How do I do post form submission processing?



>Hello,

>Just as I have an OnSubmit intrinsic event do I have something like an

>OnAfterSubmit event?

>If I don't then what do I do if I need to do processing immediately 
after

>form submission on the HTML page which contains the form?



>Code Sample :-

><FORM name="ProductForm" action="c.asp" method="post">

>         <INPUT TYPE="text" NAME="FIELD1" VALUE="VAL1" SIZE="5"/>

>         <INPUT type="submit" value="SUBMIT FORM"/>

></FORM>



>After form submission, I need to change the action attribiute to some

>other asp file eg. <FORM name="ProductForm" action="d.asp" 
method="post">

>  through DHTML after form submission.How do I do it?



>Regards,

>AMIT



     Okay, this is an odd one. Due to a technicality in how JavaScript 
and forms work, you _can't_ have an OnAfterSubmit event. Any JavaScript 
on a page exists _only_ on that page as it is currently loaded, and 
submitting a form automatically loads a new page from the server (except 
when you use a mailto form, but those are completely weird), so once you 
submit the form your code is wiped from memory. D'oh!

     However, you _can_ do what you want, but it takes some trickery. 
You'd have to use the OnSubmit handler to set a cookie for the page (not 
difficult), and your "submit" button would actually have to be a button 
that executes a bit of JavaScript code: in this case a function that 
submits the form to a URL determined by the value set in the cookie or 
lack thereof. It's an ugly kludge, but I think it should work.



PS. Why did you cross-post this to www-style? It has nothing to do with 
CSS. A lot of people are on both groups, and cross-posting just fills up 
their in-boxes that much faster.



------------ "I am not a number! I am a free man!" ---------------



                                        - The Prisoner*





*or a USC student       <gwalla@planetall.com>

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

Received on Friday, 7 August 1998 18:02:44 UTC