FP98: How to Use Active Server Pages to Calculate Form ResultsID: Q180824
|
Microsoft FrontPage includes a Save Results Form Handler that you can use to save information submitted from a form to a text file. You can also use Active Server Pages (ASP) to save submitted information to a file. This might be desirable if the FrontPage Server Extensions are not installed on the server or if calculations, such as computing sales tax, need to be performed on the submitted data.
Before you can use ASP, you must install the ASP engine on the Web server. The ASP engine can be found in the \60 Minute Intranet Kit\60 Minute Intranet Kit\Modules folder on the FrontPage 98 compact disc.
For more information about installing ASP, please see the following
article in the Microsoft Knowledge Base:
Q174185 FP98: ASP Code Displayed in BrowserTo use Active Server Pages to save the results of a form to a text file, follow these steps:
<H3> Thank you for submitting your information </H3>
<%
'-----------------------------------------------------
' FileSystemObject constants include file for VBScript
'-----------------------------------------------------
'---- iomode Values ----
Const ForAppending = 8
Const ForReading = 1
Const ForWriting = 2
'---- format Values ----
Const TristateFalse = 0
Const TristateMixed = -2
Const TristateTrue = -1
Const TristateUseDefault = -2
' If the file already exists, then an error will be generated.
' This line permits the program to continue executing on error.
On error Resume next
' Create the scripting object.
set objfso = createobject("scripting.FileSystemObject")
' Create the text file. If the file already exists, then an error
' will be generated.
set myobject = objfso.createtextfile("c:\public\myfile.txt", false)
' Open the file for scripting. If it does not exist, setting
' the third parameter (Create) to true will cause it to be created
set myobject = objfso.opentextfile ("c:\public\myfile.txt", forappending, true )
'Calculate the total price.
quantity = request.form("quantity")
price = request.form("price")
totalprice = quantity * price
' Assign the submitted form results to a variable.
productdata = request.form("name") & "," & request.form("product") &
"," & request.form("quantity") & "," & request.form("price") & "," &
totalprice
' Write the form results to the file.
myobject.writeline(productdata)
' Close the object.
myobject.close
%>
For more information about VBScript constants, please see the following article in the Microsoft Knowledge Base:
Q163009 Values for Scripting Object Constants Defined
Additional query words: 98
Keywords : kbdta fpscript
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: July 1, 1999