Solved

Pre populate a form field with value submitted on another page

Posted on 2007-04-06
8
1,577 Views
Last Modified: 2012-08-13
I have a form where the input from user are sent by mail to a specific address.
My client wants an additional feature with the form. They want a text box on all the pages to enter zio code When the user enter their zip code in the text box, and click submit,  they should be directed to the form with the zip code value which the user has submitted, already filled in the form.
The processing of the form is done in asp.
Please help how to do it.
Thank you in advance
0
Comment
Question by:soniya
8 Comments
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 18868931
if you want to pass the form's values into another new form (page), you may try use:

1. cookie, or
2. via server side scripting.

for me, i would prefer to use server side scripting since you mentioned to use asp here.
0
 
LVL 50

Accepted Solution

by:
Ryan Chong earned 50 total points
ID: 18868933
so in your second page, to auto-fill the value user had submitted, you may try like this:


<input name="zipcode" type="text" id="zipcode" value="<%=request("zipcode")%>">


where you got an element called "zipcode" in your 1st form (page) to be filled in by user.

let us know if you need futher assistance here, hope this helps
0
 
LVL 3

Author Comment

by:soniya
ID: 18869022
Please help me with the code for sending the zipcode to the quote.asp.

This is the form for Zip code input:

<form id="quoteform" method="get" action="quote.asp" ><p>
              <input type="text" name="zip" />
              <br />Enter Zip Code<br>
              <input type="submit" name="Submit" value="Enter" />
</form>

and
The form on quote.asp contains

<input name="zip" type="text" id="zip" value="<%=request("zip")%>">

Thank you
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 50

Expert Comment

by:Ryan Chong
ID: 18869131
seems your pages are working here, any problem?
0
 
LVL 3

Author Comment

by:soniya
ID: 18869188
It was not working when I posted the reply, But it is working now, thank you.
0
 

Expert Comment

by:huzefaq
ID: 22461924
zxcxzv
0
 

Expert Comment

by:doncalarco
ID: 26434408
I tried Soniya's code and nothing happened.  can the receiving page be .php?
0
 
LVL 3

Author Comment

by:soniya
ID: 26439956
You can test and see the code working at http://hues.in/zip1.asp.
These are asp files and same thing can be done in php. You will just have to replace asp code with php code.

Here is the code of my files.

#! zip.asp

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Description" content="" />
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
<meta name="author" content="Soniya Mathur" />
</head>
<body>
<div id="wrap">
  <form id="quoteform" method="get" action="zip1.asp" >
    <p>
      <input type="text" name="zip" />
      <br />
      Enter Zip Code <br />
      <br />
      <input type="submit" name="Submit" value="Enter" />
  </form>
 
</div>
</body>
</html>
++++++++++++++++++++++++++++++++++++++++++++++++++++
And
#2 zip1.asp

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Description" content="" />
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
<meta name="author" content="Soniya Mathur" />
</head>
<body>
<div id="wrap">

  <form  name="quote1" id="form2" method="post" action="zip2.asp" onload="readText(this.form)" >
    <table width="100%" border="0" cellspacing="1" cellpadding="0">
      <tr>
        <td>Name<span class="red">*</span></td>
        <td><input name="name" type="text" /></td>
      </tr>
      <tr>
        <td>Email Address<span class="red"> * </span></td>
        <td><input name="email" type="text" /></td>
      </tr>
      <tr>
        <td>Phone #1<span class="red"> *</span></td>
        <td><input name="phone1" type="text" />
          <select name="ph">
            <option selected="selected" value="Home">Home</option>
            <option value="Work">Work</option>
            <option value="Cell">Cell</option>
          </select></td>
      </tr>
      <tr>
        <td>Phone #2</td>
        <td><input name="phone2" type="text" />
          <select name="ph2">
            <option selected="selected" value="Home">Home</option>
            <option value="Work">Work</option>
            <option value="Cell">Cell</option>
            <option value="Fax">Fax</option>
            <option value="Other">Other</option>
          </select>
        </td>
      </tr>
      <tr>
        <td>Address <span class="red">*</span></td>
        <td><textarea name="address"></textarea></td>
      </tr>
      <tr>
        <td>City <span class="red">*</span></td>
        <td><input name="city" type="text" />
        </td>
      </tr>
      <tr>
        <td>State <span class="red">*</span></td>
        <td><select name="state" >
            <option value="Alabama">Alabama</option>
            <option value="Alaska">Alaska</option>
            <option value="Arizona">Arizona</option>
            <option value="Arkansas">Arkansas</option>
            <option value="California">California</option>
            <option value="Colorado">Colorado</option>
            <option value="Connecticut">Connecticut</option>
            <option value="Delaware">Delaware</option>
            <option value="Disrict of Columbia">Disrict of Columbia</option>
            <option value="Florida">Florida</option>
            <option value="Georgia">Georgia</option>
            <option value="Hawaii">Hawaii</option>
            <option value="Illinois">Illinois</option>
            <option value="Indiana">Indiana</option>
            <option value="Iowa">Iowa</option>
            <option value="Kansas">Kansas</option>
            <option value="Kentucky">Kentucky</option>
            <option value="Louisiana">Louisiana</option>
            <option value="Maine">Maine</option>
            <option value="Maryland">Maryland</option>
            <option value="Massachuesetts">Massachuesetts</option>
            <option value="Michigan">Michigan</option>
            <option value="Minnesota">Minnesota</option>
            <option value="Mississippi">Mississippi</option>
            <option value="Missouri">Missouri</option>
            <option value="Montana">Montana</option>
            <option value="Nebraska">Nebraska</option>
            <option value="Nevada">Nevada</option>
            <option value="New Hampshire">New Hampshire</option>
            <option value="New Jersey">New Jersey</option>
            <option value="New Mexico">New Mexico</option>
            <option value="New York">New York</option>
            <option value="North Carolina">North Carolina</option>
            <option value="North Dakota">North Dakota</option>
            <option value="Ohio">Ohio</option>
            <option value="Oklahoma">Oklahoma</option>
            <option value="Oregon">Oregon</option>
            <option value="Pennsylvania">Pennsylvania</option>
            <option value="Rhode Island">Rhode Island</option>
            <option value="South Carolina">South Carolina</option>
            <option value="South Dakota">South Dakota</option>
            <option value="Tennessee">Tennessee</option>
            <option value="Texas">Texas</option>
            <option value="Utah">Utah</option>
            <option value="Vermont">Vermont</option>
            <option value="Virginia">Virginia</option>
            <option value="Washington">Washington</option>
            <option value="West Virginia">West Virginia</option>
            <option value="Wisconsin">Wisconsin</option>
            <option value="Wyoming">Wyoming</option>
          </select></td>
      </tr>
      <tr>
        <td>Zip<span class="red"> *</span></td>
        <td><input name="zip" type="text" id="zip" value="<%=request("zip")%>"></td>
      </tr>
      <tr>
        <td>County <span class="red">* </span></td>
        <td><input name="county" type="text" /></td>
      </tr>
      <tr>
        <td>Reason for Request? <span class="red">*</span> </td>
        <td><select name="request1">
            <option selected="selected" value="New Purchase">New Purchase</option>
            <option value="Moving to Florida">Moving to Florida</option>
            <option value="Upset with claims">Upset with claims</option>
            <option value="Upset with service">Upset with service</option>
            <option value="Paying too much">Paying too much</option>
            <option value="Getting cancelled">Getting cancelled</option>
            <option value="Terminated due to non-payment">Terminated due to non-payment</option>
            <option value="Insuring my current home for the first time">Insuring my current home for the first time</option>
          </select>
        </td>
      </tr>
      <tr>
        <td>This home is:<span class="red"> *</span></td>
        <td><input type="text" name="thishome" /></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input type="submit" name="Submit2" value="Continue" /></td>
      </tr>
    </table>
  </form>
</div>
</body>
</html>


0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now