Source Code of formdemo.asp

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<html>
<head>
<title>Form Handler</title>
<style type="text/css">
body {color:#330000;
   background-color:#FFFFFF;
   font-family:Arial;
}
</style>
</head>
<body><h1>Your information has been received.</h1>
 <br />
 <%
 ' Loop through the fields writing out the field name and value.
 For Each Field In Request.Form
  Response.Write Field & ": " & Request.Form(Field )& "<br />" & vbCrLf
 Next
 %>
 <br />
 <form>
   <input type="button" value = "Back" onclick="javascript:history.go(-1)">
 </form>
</body>
</html>

Look a little different than your run-of-the-mill web page?
Here's some background on how it works.

  • This formdemo.asp script is invoked by the value of an action attribute on a web page containing the form. The information in the form is passed to formdemo.asp when it is invoked.
  • This Active Server Pages script uses Cascading Style Sheets (Chapter 9) to format the page background color and text.
  • VBScript (delmited by "<%" and "%>" is used to cycle through the incoming form fields and write them to the web page.
    Response.Write places information on the formdemo.asp page that is displayed in the browser.
    Request.Form inputs the form input that was passed from the web page that invoked the formdemo.asp script.
  • The form on the bottom of the page uses JavaScript (Chapter 12) and the browser history to send the visitor directly back to the form page.