...

View Full Version : Passing Form Values To Another Page



abacus566
01-15-2003, 02:38 AM
I would like to offer a "mini-form" on my homepage that would allow people to signup for my newsletter. The form would ask for their email. When they press submit, I want them to be taken to an expanded version of the form where they fill out there name and a few other details.

My question is, if they fill out their email address on my homepage, how can I get the email address value to be auto-populate on the next page?

If I'm being unclear, let me know.

I really appreciate you help!

requestcode
01-15-2003, 03:16 AM
Here is an example of hou you can send it through a URL. The first page with the form asking for the Email Address:
<html>
<head>
<title>Thank You Page Test</title>
<SCRIPT LANGUAGE="JavaScript">
function NewPage(frmobj)
{
if(frmobj.email_addr.value.length==0)
{
alert("Please Enter email address.")
frmobj.email_addr.focus()
}
else
{
var passemail=frmobj.email_addr.value
linkid="thankspage.html?"+passemail
location.href=linkid
}
}
</SCRIPT>
</head>
<body bgcolor="lightgreen" onLoad="document.myform.email_addr.focus();document.myform.reset()">
<FORM NAME="myform" onSubmit="return NewPage()">
<CENTER>
Email Address:<INPUT TYPE="text" SIZE="30" MAXLENGTH="30" NAME="email_addr">
<INPUT TYPE="button" VALUE="Send It" onClick="NewPage(this.form)"> <INPUT TYPE="reset" VALUE="Clear Form" > </CENTER>
</FORM>
</body>
</html>

The second page which displays the email address in a text box:
<html>
<head>
<title>Thanks!</title>
</head>
<body bgcolor="lightblue">
<FORM NAME="myform">
<INPUT TYPE="text" NAME="email" SIZE="30">
</FORM>
<SCRIPT LANGUAGE="JavaScript">
var passdata=unescape(location.search.substring(1,location.search.length))
document.myform.email.value=passdata
</SCRIPT>
</body>
</html>

Also here is a link to a tutorial that give an explanation of how it works:
http://www.javascriptkit.com/javatutors/send1.shtml

Hope that helps and good luck.

abacus566
01-15-2003, 04:21 AM
Thank you so much!

This board is such a great group of people. I have been an observer for sometime. Everyone always gets the help they need.

Stoffel
01-20-2003, 05:30 PM
Hmz,

It seems that u understand the code very well Requestcode

Now I have a question.

This script works grate, but can it be modified so the text that u send to another page will not apear in a textbox but in plain text so I can put it on my webpage. This way the script will serve as a "Next" button, on when clicked brings u to a page where u can verify your data and then let it be send to me.

requestcode
01-20-2003, 05:55 PM
You want to display the data and if it is correct they can have it emailed to you or if it is not correct then send them back to the preveious page? Are you using a server side script to mail the data or the "mailto:" in the action field.

Stoffel
01-20-2003, 05:56 PM
yes, I found a script to let it be sent to me



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum