Re: populate fields of 2nd form from 1st?

by "Darrell King" <darrell(at)webctr.com>

 Date:  Tue, 5 Sep 2000 07:51:44 -0400
 To:  <hwg-techniques(at)hwg.org>
 References:  hotmail
  todo: View Thread, Original
You could also carry smaller amounts of info through in a JavaScript-set
cookie if the second form is under the same domain as the first.  Of course,
a user without JS doesn't get the benefit of the effect...

By far, the most elegant way is to user server-side scripting.  I would use
Perl, and others might choose PHP, ASP or another option.  The common
denominator, though, is that the forms are dynamically generated by the
script at the server level, which means anything you want can be included
programmatically.

As a side note, these forms are so useful and versatile that they are now a
standard part of my company's new site designs.  Besides carrying fields,
they also include error checking that returns to user to an unchanged form
for corrections and they can change configuration according to the user's
needs.

D


----- Original Message -----

>We have a job where we'd like information entered in the fields
>of a form on one page, to populate some of the fields on another.
>
>The fields whose values are to be copied over will be of the same
>type and length.
>
>How can we best do this?  JavaScript?  Custom CGI for the forms?

It can be done by JavaScript if you use frames. Then you'll have to declare
some variables in the frameset page, like

var formname,formaddress;

In the form, use an onSubmit script to fill these variables with the stuff
the user has filled in, like:

top.formname = document.forms[0].name.value;
top.formaddress = document.forms[0].address.value;

If you load a new form page, use an onLoad script to see if the variables
are filled, and if they are write them to the form:

if (top.formname) document.forms[0].name.value = top.formname;
if (top.formaddress) document.forms[0].address.value = top.formaddress;

Hope this is clear,

ppk

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA