When a user enters information into a FORM and sends it to a server to be processed it is called "submitting" a FORM. When a user submits a FORM the data from each entry field is sent to the HTTP server along with the name of the field the data was entered in. An example of an input field in a form is:
<INPUT TYPE=text NAME="input-field-1">Which, in a FORM, would look like:
Here the data entered would be associated with the input field input-field-1.
When Zot-Dispatch E-mails, Reflects, or Appends data from a FORM, the author of the FORM can choose how that data is to be represented. The default representation in Zot-Dispatch is a listing of all the input field names and the values that were entered for each field. However, Zot-Dispatch gives the author of a FORM the option of choosing exactly how the data is to be represented.
A Template is a body of text which is marked up so that the values of input fields from a FORM can be placed into the text resulting in a desirable formatting of the data when it is dispatched.
A body of text is marked up as follows: In each place in the text where you would like the value entered into an input field substituted, place in the text, the name of the input field preceded by a dollar sign ($), and followed by a pound sign(#). (for example, $input-field-1#) More examples will come later.
When the form is submitted, Zot-Dispatch will replace all input field names with their corresponding values given that those values exist. The resulting document will be dispatch in the desired manner (e-mail, reflect, append).
If no value for an input field named in the Template is given, the dollar sign and the pound sign will be stripped off leaving just the name of the input field where the value should have been.
If a literal dollar sign is needed in the text of the Template, two consecutive dollar signs ($$) must be used instead. Zot-Dispatch will replace the two dollar signs with one before it is finished.
An Example Template
Suppose you have the following Template:
Dear $TO#, I think the idea of a template is $FEELING#. I'd pay $$$MONEY# for it. Sincerely, $FROM#And suppose the input fields TO, FEELING, and FROM were put in a FORM by an author as follows:
<INPUT TYPE=text NAME="TO" VALUE="John Doe"> <INPUT TYPE=text NAME="FEELING" VALUE="wonderful"> <INPUT TYPE=text NAME="MONEY" VALUE="5.00"> <INPUT TYPE=text NAME="FROM" VALUE="Jane Doe">After Zot-Dispatch has finished substituting the values of the input fields into the Template the resulting text is:
Dear John Doe, I think the idea of a template is wonderful. I'd pay $5.00 for it. Sincerely, Jane DoeAll the input field names in the text have been replaced by the values that were set in the FORM, and the two consecutive dollar signs have been reduced to one literal dollar sign.
Templates are great if you would like the results of your FORM returned to you in an easily readable form, or if the results of your FORM are to be fed into another program which needs the data in a particular format. Exactly how to define a Template in a FORM will be described at a later time.
Note: In FORMS it is possible to give the same name to more than one input field. If an input field is named in a Template and more than one input field has that name resulting in more than one value being returned the HTTP server, Zot-Dispatch will only substitute the last value associated with that input field name.
This can be used to your advantage, however, by allowing default values of variables to be defined. For example, if you have a Template into which will be substituted a variable named variable-name, and you have the following in your FORM:
<INPUT TYPE=hidden NAME=variable-name VALUE="default value"> <INPUT TYPE=checkbox NAME=variable-name VALUE="selected value">If the checkbox is selected by the user, both values will be returned to Zot-Dispatch but only the last will be used (the selected value), but if the checkbox is not selected then only the default value will be returned to Zot-Dispatch and used.
Return to the Zot-Dispatch Documentation page