Solved

Pre populate a form field with value submitted on another page

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

Expert Comment

by:Ryan Chong
Comment Utility
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 49

Accepted Solution

by:
Ryan Chong earned 50 total points
Comment Utility
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
Comment Utility
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
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
seems your pages are working here, any problem?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 3

Author Comment

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

Expert Comment

by:huzefaq
Comment Utility
zxcxzv
0
 

Expert Comment

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

Author Comment

by:soniya
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 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

18 Experts available now in Live!

Get 1:1 Help Now