Solved

Pre populate a form field with value submitted on another page

Posted on 2007-04-06
8
1,579 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 51

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 51

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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 51

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

830 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