CGI Program: form-maker


Description

A general purpose script that dynmically creates an HTML form using a template file. It reads variables from the URL, and inserts those variables in the form when it is displayed. It will also replace text strings in the form template. This means we can have a variety of similar forms that are based on a single template.

Examples

The script is normally invoked with a URL using method=get. For an example, see
http://www.columbia.edu/httpd/cgi/form-maker-example.html
This example uses the template in
http://www.columbia.edu/httpd/cgi/form-maker-template.html
The form-maker script can also be invoked using method=post. In this case you would use hidden variables to pass the necessary information, instead of embedding that information in the URL. For an example, see
http://www.columbia.edu/httpd/cgi/form-maker-post.html

Variables

When invoked with method=GET, variables appear at the end of the URL in the format
?variable1=value1&variable2=value2&variable3=value3
The variables can appear in any order. One of those variables must be "template", which specifies the URL of the template file, for example
template=/http/cgi/form-maker-template.html
The template file name must end in "template.html", for security reasons. If the file name ends in "cu-template.html" the form will be restricted to users in the columbia.edu domain.

The variables in the URL are added to the template before the </form> tag, so they override any variables that are included in the template. That means you can include default values in the template. They will be present in the dynamic form if they are not overriden in the URL.

The "template" variable is required by form-maker, all other variables will be specific to your application. For example, you could include the "file_dest" variable if your template uses the generic-inbox script.

file_dest=~ark7/inbox
In addition to hidden variables, you can also replace text strings in the template. Our example illustrates this using the "bkname" variable. The template includes the text "$bkname" in the place(s) where this text replacement is to occur. We pass this information to the form-maker script by including it in the URL
bkname=Moby+Dick
In the resulting form you will see the text "Moby Dick" instead of $bkname. This text replacement can occur wherever you like: in the descriptive text, part of a header, an input field, a select option, etc. Notice that the space character has been replaced with "+" so it can be included in the URL that invokes form-maker. Other special characters can also be included using the % prefix notation, which is defined in the HTTP specification. For example you can use %7F to represent tilde (~) because the numeric value of ASCII tilde is hex 7F.

Pager Variable

The pager variable can be used in forms that require links to the "next" and "previous" pages. This variable can be set to a comma separated list of four values: current page number, first page, last page, and next template. The next template can be omitted if it is the same as the current template. For example

pager=2,1,10
pager=2,1,10,bk-template.html

When the pager variable is set, form-maker will replace template variables called pagination_current, pagination_previous, pagination_next, and template_url. The "next" and "previous" links will call form-maker again with the correct pager values for the next and previous pages.


Last modified 12/26/06 19:39
Research and Development Group
Academic Information Systems
Columbia University
Help Line: 212 854.1919
Email: consultant@columbia.edu