How to collect user input from a form and store it into a file
Overview
This script demonstrates how to use an HTML form, process it locally and store the data into an external file. The script is not especially useful in itself, but can serve as a starting point for your own efforts.
Requirements Instructions - Create an HTML page, in your source folder, containing the HTML form code. As we are processing the form locally we need to use METHOD="POST" and set ACTION= to point to an Activ Link, in this example, #!writefile.as to run the writefile.as Activ Script when the form is submitted.
- Create an Activ Script, in this example called writefile.as, in your source folder using a text editor like Notepad. This script runs when the user submits the form and saves the data to the file.
Please note: If using Notepad on a version of Windows prior to Windows XP, when you save in Notepad, be sure to place the file name in quotes on the Save As dialog box, i.e. "setmark.as" otherwise Notepad will add .txt to the end of the name (giving a file name of writefile.as.txt). If using Notepad on Windows XP, this workaround is not necessary.
Notes - This script has been tested with Activ E-Book Compiler versions 4.20, 4.21 and 4.22 (4.22 is the latest version at the time of writing). It is possible that changes might be required for e-books made with subsequent versions.
- This script will not work with versions of Activ E-Book Compiler prior to 4.20.
|
|