HOWTO: Create a Recursive Form Using Active Server Pages

ID: Q191565

The information in this article applies to:

SUMMARY

This article explains one possible way to write Active Server Pages (ASP) code using VBScript to provide a recursive functionality within your ASP page.

MORE INFORMATION

Recursive means that the ASP page will call itself to continue with functionality. In the example below the page will post form values to itself for processing. This is by no means necessary in all applications, it is merely provided as a more robust method to achieve functionality. One advantage to this method is fewer ASP pages to maintain. For example a developer could make a self-contained "wizard" all in one ASP page.

This sample demonstrates the functionality with one post to itself.

Place this code in a plain text document and save it as "Recursive.asp."

   =========
   <%@ LANGUAGE="VBSCRIPT" %>
   <%
      submitted = Request.Form("frmSubmit")
   %>
   <HTML>
   <HEAD>
   <TITLE>Recursive Example</TITLE>
   </HEAD>
   <BODY>
   <%
   If submitted <> "yes" Then
   %>
   <h3>Recursive Example</h3>
   <form action="<%=Request.Servervariables("SCRIPT_NAME")%>" method="post"
                                                             name="myForm">
   <input type="hidden" name="frmSubmit" value="yes">
   Please enter some text:<br><input type="text" name="frmInput"><p>
   <input type="submit" name="myButton" value="Click here to continue">
   </BODY>
   </HTML>
   <%
    ElseIf submitted = "yes" Then
   %>
   <h3>Form Has been submitted</h3>
   This is the information you submitted:<p>
   <%=Request.Form("frmInput")%>
   </BODY>
   </HTML>
   <%
   End If
   %>

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS KB IS AT YOUR OWN RISK. Microsoft provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. Microsoft provides examples of Visual Basic Script procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic Script procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular procedure, they will not modify these examples to provide added functionality, nor will they help you construct procedures to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom procedures. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

Keywords          : kbASP kbGrpASP 
Version           : WINDOWS:2.0; WINNT:
Platform          : WINDOWS winnt
Issue type        : kbhowto

Last Reviewed: August 26, 1998