<variables>

New to Version 2.0: This marks the beginning of the variables section. In this section of the form, you define which variables you want to work with in your form, what name you'd like to associate with them, and their values. Within the form, <variables> exists at the same level in the form hierarchy as <controls> and <parameters>.  

 

<variables> has no attributes, but it has one type of child tag: <variable> which does have attributes.

 

USAGE:

By themselves, variables aren't of much value. However, they become powerful when you use them in your form. You can assign the value of a variable as the default value of a text box, for instance. Or you can assign it as the value of a <hidden> field to save it with the data the user enters in the form or to pass it through via HTTP POST to another program. You can even assign a style tag to a variable and use it repeatedly throughout the form to save time and avoid typing errors. As XMod continues to grow, variables will play an even more substantive part in the creation of forms.

 

To use variable values, you put placeholders in your form code where you want the variable's value to go. Placeholders look like this: {MyVariable}  where the name the variable is enclosed in brackets. That's all there is to it. At run-time, XMod will replace those placeholders with the variable's value. Note that variable names must be unique within the form, among all variables, parameters, and controls.

 

ATTRIBUTES <variable>:

name

This is the name of the variable. The name must be unique among all variables, parameters, and form controls names (ref's). This is the name you'll place within brackets { } to tell XMod where to place the variable's value.  (Required)

value

This is the value that XMod will use to replace the placeholders it find with the variable's name.

 

EXAMPLES:

In the example below, you can see how to define your parameters for XMod and how to use them. The relevant areas are marked in red.

 

<form format="custom">

  <parameters>

    <parameter name="uid" alias="UserId" default="-1"></parameter>

    <parameter name="bookname" alias="BookTitle" default="" />

  </parameters>

  <variables>

    <variable name="vCellHeader" value="border: 1px red solid; background-color:navy; color:yellow;"/>

    <variable name="MySecretCode" value="12345"></variable>

  </variables>

  <controls>

    <literal>

      <!--Everything in here is HTML -->

      <table style="{vCellHeader}">

<tr>

  <td><h2>Welcome To My Custom Form</h2></td>

</tr>

      </table>

      <table width="400" cellpadding="3" style="{vCellHeader}">

        <tr>

          <td style="background-color:maroon; color:white;">

            Your Name:</td>

          <td>

    </literal>

            <input ref="Title" width="250px" class="NormalTextBox">

              <label>Title</label>

              <default>{BookTitle}</default>

            </input>

    <literal>

          </td>

        </tr>

      </table>

    </literal>

    <hidden ref="CustomerId">{UserId}</hidden>

    <hidden ref="SuperSecretCode">{MySecretCode}</hidden>

    <hidden ref="DuplicateSecretCode">{MySecretCode}</hidden>

  </controls>

</form>