Transform Examples


Below are some Transform examples. These application weren't designed to look good; only demonstrate Transform features. These examples also show one approach; other approaches are possible. If there are examples you'd like to see included here (or have examples to contribute), send email to percival@indiana.edu.

Feel free to try these examples out. Occasionally I'll go in and clean out the data files these examples create.

A Simple "Email a Question" Example

This example demonstrates a simple form which allows users to enter a question that is sent as an email message and then delivers a "Thank You" page. Feel free to try this - it will not actually send any email.

A Simple "Email a Question" Example with Required Fields

This is exactly like the last example except that it demonstrates how to specify that variables are required, that is, an error message is delivered if the user doesn't complete fields you've specified as required.

A Simple "Email a Question" Example with Required Fields and Appending to a file.

This is exactly like the last example except that it also demonstrates how you can have Transform append submitted form data to a file.

Sample Guestbook

This simple guestbook example demonstrates using two submit buttons with different names to control whether a "review" or "submit" *success-response* is delivered (via !use-if). The "review" section demonstrates having a form in a *success-response* with no input fields (just a submit button); the !carry-forward command is being used to create hidden form variables.

Sample Rideboard

This ride board example demonstrates multiple *success-response*s and conditional branching, using !carry-forward, and using variable names in !append-file-name and !append-after to dynamically set append file names and the location information is written in the append file. It also demonstrates how !print-if can control what information is output. Note that this example also has "review" and "submit" buttons, but unlike the Guestbook example above, these two buttons have the same name, but different values.

A silly error response example

This rather silly example shows how you can use !print-if in an *error-response* to continually regenerate a form until the user enters all required values. Any values entered by the user are used to prefill the form. This example also demonstrates why you might want to include the !use-linebreak-mode command in an individual section. Note, there is one problem with the approach demonstrated here; if the user uses the browser's "Back" button, they will go back through all previous attempts at completing the form. If you choose to use this method, you should probably give the users a convenient link to some previous page.

A silly error response example - number 2

This example is exactly like the one above except that in this case, when the user completes a field, that field doesn't appear in subsequent forms; only those fields that weren't completed appear. If you view the source, you'll see that the completed fields are coded as hidden form values.

Items for sale

This "items for sale" examples demonstrates using two *append-response* sections. One writes the user supplied information to a unique file (using [!TIME]). The other appends a link and title to an index listing of all available files. Thus, rather than just appending information to one continuous file like some of the examples above, here a link to a newly created independent file is created.

Items for sale number 2

This "items for sale" is exactly like the last with one little twist. Here we want to provide an error message to the user if they don't enter EITHER their phone number or e-mail address; one is sufficient, but they must enter one. This example demonstrates how a *success-response* section can be used to deliver an error message. Comments in the template file describe how this is accomplished.