Skip To Main Content | Home | Sitemap | Contact
Latest Visitors: United States's flagUnited States's flagUnited States's flagUnited States's flagUnited States's flagItaly's flagSweden's flagUnited States's flagSweden's flagUnited States's flagUnited States's flagLatvia's flagParaguay's flagHungary's flagFrance's flagUnited States's flagKenya's flagUnited States's flagUnited States's flagUnited States's flagNetherlands's flagChina's flagChina's flagUnited States's flagUnited States's flag
 

How can you have a multiple page form so entries can be made in steps?

This is just one method to have a multi-page form and maintain the form values. The user can return to any form page to edit previously entered information.  The values entered on each form are maintained until the form is submitted.  (In this example, by hidden fields and cookies). Once the form is submitted the cookie is emptied and a session variable is set to help prevent multiple orders.

For these example pages, you can see all three form pages. You would not do this in production.

Edit Contact Information | Edit Order Information | Edit Shipping & Payment Information

Form 1 - Contact  

Enter Your Contact Details









Form 2 - Products (Would be hidden)



Form 3 - Shipping and Payment (Would be hidden)












<%
Option Explicit
Session.CodePage=65001
Response.Charset="UTF-8"
if session("orderstatus")="submitted" then
  response.redirect("http://www.rodsdot.com/ee/form3neworder.asp")
end if

Dim fname, lname, address, city, state, zipcode
Dim quantity1, quantity2, quantity3, quantity4
Dim product1, product2, product3, product4
Dim sfname, slname, saddress, scity, sstate, szipcode
Dim smethod, cardtype, cardnumber, cc2, expirationdate

if LCase(request.servervariables("HTTP_METHOD"))="post" then
  fname = getPostedFieldFiltered("fname")
  lname = getPostedFieldFiltered("lname")
  address = getPostedFieldFiltered("address")
  city = getPostedFieldFiltered("city")
  state = getPostedFieldFiltered("state")
  zipcode = getPostedFieldFiltered("zipcode")
  quantity1 = getPostedFieldFiltered("quantity1")
  quantity2 = getPostedFieldFiltered("quantity2")
  quantity3 = getPostedFieldFiltered("quantity3")
  quantity4 = getPostedFieldFiltered("quantity4")
  product1 = getPostedFieldFiltered("product1")
  product2 = getPostedFieldFiltered("product2")
  product3 = getPostedFieldFiltered("product3")
  product4 = getPostedFieldFiltered("product4")
  sfname = getPostedFieldFiltered("sfname")
  slname = getPostedFieldFiltered("slname")
  saddress = getPostedFieldFiltered("saddress")
  scity = getPostedFieldFiltered("scity")
  sstate = getPostedFieldFiltered("sstate")
  szipcode = getPostedFieldFiltered("szipcode")
  smethod = getPostedFieldFiltered("smethod")
  cardtype = getPostedFieldFiltered("cardtype")
  cardnumber = getPostedFieldFiltered("cardnumber")
  cc2 = getPostedFieldFiltered("cc2")
  expirationdate = getPostedFieldFiltered("expirationdate")
  Response.Cookies(Session.SessionID)=Session.SessionID
  Response.Cookies(Session.SessionID)("fname")=fname
  Response.Cookies(Session.SessionID)("lname")=lname
  Response.Cookies(Session.SessionID)("address")=address
  Response.Cookies(Session.SessionID)("city")=city
  Response.Cookies(Session.SessionID)("state")=state
  Response.Cookies(Session.SessionID)("zipcode")=zipcode
  Response.Cookies(Session.SessionID)("quantity1")=quantity1
  Response.Cookies(Session.SessionID)("quantity2")=quantity2
  Response.Cookies(Session.SessionID)("quantity3")=quantity3
  Response.Cookies(Session.SessionID)("quantity4")=quantity4
  Response.Cookies(Session.SessionID)("product1")=product1
  Response.Cookies(Session.SessionID)("product2")=product2
  Response.Cookies(Session.SessionID)("product3")=product3
  Response.Cookies(Session.SessionID)("product4")=product4
  Response.Cookies(Session.SessionID)("sfname")=sfname
  Response.Cookies(Session.SessionID)("slname")=slname
  Response.Cookies(Session.SessionID)("saddress")=saddress
  Response.Cookies(Session.SessionID)("scity")=scity
  Response.Cookies(Session.SessionID)("sstate")=sstate
  Response.Cookies(Session.SessionID)("szipcode")=szipcode
  Response.Cookies(Session.SessionID)("smethod")=smethod
  Response.Cookies(Session.SessionID)("cardtype")=scardtype
else
  if Request.Cookies(Session.SessionID).haskeys then
    fname = getCookieFieldFiltered("fname")
    lname = getCookieFieldFiltered("lname")
    address = getCookieFieldFiltered("address")
    city = getCookieFieldFiltered("city")
    state = getCookieFieldFiltered("state")
    zipcode = getCookieFieldFiltered("zipcode")
    quantity1 = getCookieFieldFiltered("quantity1")
    quantity2 = getCookieFieldFiltered("quantity2")
    quantity3 = getCookieFieldFiltered("quantity3")
    quantity4 = getCookieFieldFiltered("quantity4")
    product1 = getCookieFieldFiltered("product1")
    product2 = getCookieFieldFiltered("product2")
    product3 = getCookieFieldFiltered("product3")
    product4 = getCookieFieldFiltered("product4")
    sfname = getCookieFieldFiltered("sfname")
    slname = getCookieFieldFiltered("slname")
    saddress = getCookieFieldFiltered("saddress")
    scity = getCookieFieldFiltered("scity") 
    sstate = getCookieFieldFiltered("sstate")
    szipcode = getCookieFieldFiltered("szipcode")
    smethod = getCookieFieldFiltered("smethod")
    cardtype = getCookieFieldFiltered("cardtype")
    cardnumber = getCookieFieldFiltered("cardnumber")
    cc2 = getCookieFieldFiltered("cc2")
    expirationdate = getCookieFieldFiltered("expirationdate")
  else
    session("orderstatus")="new"
  end if
end if

function getPostedFieldFiltered(fldName)
  '**********************************************
  '* PURPOSE: Retrieves a posted form field and
  '* ensures it contains only safe characters
  '* as defined by a regular expression.
  '* INPUT: The field name
  '* OUTPUT: The field value if it contains only
  '* allowed characters, otherwise an empty
  '* string.
  '**********************************************
  Dim tmp, strIn, regEx, pattern, matches, match
  tmp = ""
  strIn = request.form(fldName)
  Set regEx = New RegExp
  regEx.pattern = "[\w\.\ \,\-\&\/\:]{1,255}"
  regEx.IgnoreCase = false
  regEx.Global = True
  Set Matches = regEx.Execute(strIn)
  for each match in matches
    tmp = tmp & match
  next
  if tmp = strIn then
    getPostedFieldFiltered = tmp
  end if
end function 

function getCookieFieldFiltered(fldName)
  '**********************************************
  '* PURPOSE: Retrieves a posted form field and
  '* ensures it contains only safe characters
  '* as defined by a regular expression.
  '* INPUT: The field name
  '* OUTPUT: The field value if it contains only
  '* allowed characters, otherwise an empty
  '* string.
  '**********************************************
  Dim tmp, strIn, regEx, pattern, matches, match
  tmp = ""
  strIn = request.cookies(Session.SessionID)(fldName)
  Set regEx = New RegExp
  regEx.pattern = "[\w\.\ \,\-\&\/\:]{1,255}"
  regEx.IgnoreCase = false
  regEx.Global = True
  Set Matches = regEx.Execute(strIn)
  for each match in matches
    tmp = tmp & match
  next
  if tmp = strIn then
    getCookieFieldFiltered = tmp
  end if
end function 
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005-2010 Roderick Divilbiss">
<title>rodsdot.com :: multi-step form 1 of 3</title>
<style type="text/css">
<!--
label {
  position:relative;
  float:left;
  width:125px;
}
-->
</style>
</head>

<body>
<p><strong>Edit Contact Information</strong> | <a href="form2of3.asp">Edit Order Information</a> | <a href="form3of3.asp">Edit Shipping & Payment Information</a> 
<form name="frmEntry" method="post" action="form2of3.asp">
  <fieldset style="background-color: #EFEFEF">
    <legend>Form 1 - Contact</legend>
    <h2>Enter Your Contact Details</h2>
    <label for="fname">First Name</label><input type="text" id="fname" name="fname" value="<%=fname%>" size="25"><br>
    <label for="lname">Last Name</label><input type="text" id="lname" name="lname" value="<%=lname%>" size="25"><br>
    <label for="address">Address</label><input type="text" id="address" name="address" value="<%=address%>" size="35"><br>
    <label for="city">City</label><input type="text" id="city" name="city" value="<%=city%>" size="25"><br>
    <label for="state">State</label><input type="text" id="state" name="state" value="<%=state%>" size="10"><br>
    <label for="zipcode">Zip Code</label><input type="text" id="zipcode" name="zipcode" value="<%=zipcode%>" size="15"><br>
    <br>
    <input type="submit" name="submit" value="Next Page"><br>
  </fieldset>
  <input type="hidden" id="quantity1" name="quantity1" value="<%=quantity1%>">
  <input type="hidden" id="product1" name="product1" value="<%=product1%>">
  <input type="hidden" id="quantity2" name="quantity2" value="<%=quantity2%>">
  <input type="hidden" id="product2" name="product2" value="<%=product2%>">
  <input type="hidden" id="quantity3" name="quantity3" value="<%=quantity3%>">
  <input type="hidden" id="product3" name="product3" value="<%=product3%>">
  <input type="hidden" id="quantity4" name="quantity4" value="<%=quantity4%>">
  <input type="hidden" id="product4" name="product4" value="<%=product4%>">
  <input type="hidden" id="sfname" name="sfname" value="<%=sfname%>">
  <input type="hidden" id="slname" name="slname" value="<%=slname%>">
  <input type="hidden" id="saddress" name="saddress" value="<%=saddress%>">
  <input type="hidden" id="scity" name="scity" value="<%=scity%>">
  <input type="hidden" id="sstate" name="sstate" value="<%=sstate%>">
  <input type="hidden" id="szipcode" name="szipcode" value="<%=szipcode%>">
  <input type="hidden" id="smethod" name="smethod" value="<%=smethod%>">
  <input type="hidden" id="cardtype" name="cardtype" value="<%=cardtype%>">
  <input type="hidden" id="cardnumber" name="cardnumber" value="<%=cardnumber%>">
  <input type="hidden" id="cc2" name="cc2" value="<%=cc2%>">
  <input type="hidden" id="expirationdate" name="expirationdate" value="<%=expirationdate%>">
</form>
</body>

</html>