A form that remembers
Overview
This script demonstrates how to remember user input to a form, and display back.
Requirements Instructions - First you need to create an HTML page that links to the form. In this example, I have created a minimal page, the important line being the one that begins <A HREF=...
- Next you need to create the HTML code that goes above and below the FORM (the top and bottom of the page). The easiest way to do this is to create 2 files (using say Notepad) outside the source folder (say in the include folder) contain this code. Then add 2 Activ variables, both of type Compile Time Include HTML Fragment called say top and bot, and then select the corresponding files.
Here's what I put in the file used for the top variable: Here's what I put in the file used for the bot variable: - The next step is to create a script to display the form. In my example, this script is called showform.as. You can create this using Notepad or any other plain text editor.
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. "showform.as" otherwise Notepad will add .txt to the end of the name (giving a file name of showform.as.txt). If using Notepad on Windows XP, this workaround is not necessary.
My script will read the value to display in the form field from an INI file called myform.ini (you can and should change that), then generate the form page using the top and bot variables that I made earlier, plus the form itself inserted in between.
Here is my showform.as file (the lines beginning with REM are comments explaining what the script does):
- The last part is to create the script that is run when the form is submitted.
If you look carefully at the previous step, you'll see that the form is linked to a script called doform.as.
So here is my doform.as script (again, create this with a plain text editor and place in your source folder along with the HTML files).
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. "doform.as" otherwise Notepad will add .txt to the end of the name (giving a file name of doform.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.
|
|