2025-04-27 07:49:33 -04:00

181 lines
7.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<TITLE>ProcessForm</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
TempString = navigator.appVersion
if (navigator.appName == "Microsoft Internet Explorer"){
// Check to see if browser is Microsoft
if (TempString.indexOf ("4.") >= 0){
// Check to see if it is IE 4
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
}
}
else if (navigator.appName == "Netscape") {
// Check to see if browser is Netscape
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
//-->
</script>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Window_OnLoad()
Dim frmContents
On Error Resume Next
If Not Parent Is Nothing Then
Set frmContents = Parent.Contents
If Not frmContents Is Nothing Then
frmContents.Window.TOCSynch_Click
End If
End If
End Sub
//--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="MS-IT-LOC" Content="Internet Information Services">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H2><A NAME="_processform"></A><SUP></SUP>ProcessForm</H2>
<P>The <B>ProcessForm </B>method merges data from a template file with form data submitted by a user, and creates a new file. The data submitted by the user can be manipulated by script in the template file.</P>
<H6>Syntax</H6>
<P><I>oTools</I><B>.ProcessForm(</B><I>OutputFileURL</I>, <I>TemplateURL</I>, [<I>InsertionPoint</I>]<B>)</B></P>
<P>&nbsp;</P>
<H6>Parameters</H6>
<DL>
<DT><I>OutputFileURL</I></DT>
<DD>A string containing the relative URL of the file to which the merged data is written. <BR>
</DD>
<DT><I>TemplateURL </I></DT>
<DD>A string containing the relative URL of the template file. <BR>
</DD>
<DT><I>InsertionPoint </I></DT>
<DD>An optional parameter indicating where in the template file to start inserting the process data. This parameter has not been implemented. If you include a value for this parameter it will be ignored.<BR>
</DD>
<DT></DT>
</DL>
<P><span class=le><B>Note</B></span></P>
<P>The template file can contain ASP scripts. </P>
<P>A script between &lt;% and %&gt; delimiters is treated just like other text in the template and copied into the output file. If the output file is an ASP document, the script will run when the output file is executed.</P>
<P>If you want script in the template to be executed during the call to ProcessForm, place your code between special &lt;%% and %%&gt; delimiters. Since these scripts are executed before the template data is saved in the output file, the results get saved in the output file, usually as standard text. </P>
<P>If the specified output file exists, the server will overwrite it.</P>
<P>If the <I>InsertionPoint</I> parameter does not exist, Tools.ProcessForm replaces the entire output file. If the <I>InsertionPoint</I> parameter exists, and does not begin with an asterisk (*), Tools.ProcessForm finds the <I>InsertionPoint</I> string in the output file and inserts the data immediately after it. If the <I>InsertionPoint</I> string begins with an asterisk (*), Tools.ProcessForm finds the <I>InsertionPoint</I> string in the output file and inserts the data immediately before it. If the <I>InsertionPoint</I> string exists, but is not found in the output file, the data is appended to the end of the file.</P>
<H6>Example</H6>
<P>The following example uses two files. Tools_Template.asp is a template file for a personal Web page. Tools_ProcessForm.asp takes some input from a user, and calls <B>ProcessForm</B> to copy the template data to a new file with the updates given by the user. Run the example by browsing to Tools_ProcessForm.asp.</P>
<P>--- Tools_Template.asp ---</P>
<PRE><CODE>&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;&lt;%% =Request.Form("company") %%&gt;&lt;/TITLE&gt;
&lt;/HEAD&gt;
&lt;BODY bgcolor="&lt;%% =Request.Form("bgcolor") %%&gt;"&gt;
&lt;FONT face="&lt;%% =Request.Form("fface") %%&gt;" size=&lt;%% =Request.Form("fsize") %%&gt;&gt;
&lt;H5 align=center&gt;This file was created on &lt;%% =Date %%&gt; at &lt;%% =Time %%&gt;&lt;/H5&gt;
&lt;%
Response.Write "&lt;H3 align=center&gt;Welcome to the home page for:&lt;/H3&gt;"
Response.Write "&lt;H1 align=center&gt;&lt;%% =Request.Form("company") %%&gt;&lt;/H1&gt;"
Set MyPageCounter = Server.CreateObject("MSWC.PageCounter")
MyPageCounter.PageHit
Response.Write "&lt;P align=center&gt;This page has been hit " &amp; MyPageCounter.Hits &amp; " times."
%&gt;
&lt;P&gt;&lt;B&gt;About my Company:&lt;/B&gt;
&lt;P&gt;&lt;%% =Request.Form("about") %%&gt;
&lt;/FONT&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;</CODE></PRE>
<P>--- Tools_ProcessForm.asp ---</P>
<PRE><CODE>&lt;HTML&gt;
&lt;HEAD&gt;&lt;TITLE&gt;&lt;/TITLE&gt;&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;%
OutputURL = Request.Form("outputurl")
BGColor = Request.Form("bgcolor")
FFace = Request.Form("fface")
FSize = Request.Form("fsize")
Company = Request.Form("company")
About = Request.Form("about")
Process = True
If "" = OutputURL Then Process = False
If "" = BGColor Then Process = False
If "" = FFace Then Process = False
If "" = FSize Then Process = False
If "" = Company Then Process = False
If "" = About Then Process = False
%&gt;
&lt;H3&gt;Create a Default Company Page Using the Tools_Template.asp Template&lt;/H3&gt;
Please fill out the form. All fields are required.
&lt;FORM NAME="GetTemplateStuff" METHOD="POST" ACTION="Tools_ProcessForm.asp"&gt;
&lt;input type="TEXT" NAME="outputurl" size=70 value="&lt;%=OutputURL%&gt;"&gt; Relative Output URL&lt;BR&gt;
&lt;input type="TEXT" NAME="bgcolor" size=70 value="&lt;%=BGColor%&gt;"&gt; Background Color&lt;BR&gt;
&lt;input type="TEXT" NAME="fface" size=70 value="&lt;%=FFace%&gt;"&gt; Font Face&lt;BR&gt;
&lt;input type="TEXT" NAME="fsize" size=70 value="&lt;%=FSize%&gt;"&gt; Font Size&lt;BR&gt;&lt;BR&gt;
&lt;input type="TEXT" NAME="company" size=70 value="&lt;%=Company%&gt;"&gt; Company Name&lt;BR&gt;
&lt;input type="TEXT" NAME="about" size=70 value="&lt;%=About%&gt;"&gt; About Your Company&lt;BR&gt;&lt;BR&gt;
&lt;INPUT type="SUBMIT" VALUE="Create File"&gt;
&lt;/FORM&gt;
&lt;%
If Process Then
Set oTools = Server.CreateObject("MSWC.Tools")
oTools.ProcessForm OutputURL,"Tools_Template.asp","&lt;HTML*&gt;"
%&gt;
&lt;P&gt;&lt;A href="&lt;%=OutputURL%&gt;"&gt;&lt;%=OutputURL%&gt;&lt;/A&gt; was created.
&lt;%
Else
Response.Write "No file was created because of missing inputs."
End If
%&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
</CODE></PRE>
<H6>See Also</H6>
<P><A HREF="/iishelp/iis/htm/asp/comp1d9v.htm"><B>FileExists</B></A>, <A HREF="/iishelp/iis/htm/asp/comp8kdp.htm"><B>Random</B></A> </P>
<hr class="iis" size="1">
<p align="center"><em><a href="../../../common/colegal.htm">&copy; 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
</BODY>
</HTML>