If, Then Comparisons

Example

Displaying a tax statement for form orders from North Carolina.

MGI Tags

  • mgiIf

Steps

  1. Create an order form and form processing page.
  2. Open the form processing page in a text editor.
  3. Insert the mgiIf tag.
  4. Save the form processing page.
  5. FTP the order form and form processing page to the web server running MGI.
  6. Complete and submit the form.


Step 1: Create an order form and form processing page.

Create an order form that collects a product or service order, the customer's shipping information including state, and payment information, for example. Create a form to email processing page. (See the forms to email instructions for more information).

Step 2: Open the form processing page in a text editor.

Open the form processing page in a text editing program that allows you to view and modify the HTML of your page.

Step 3: Insert the mgiIf tag.

Insert your cursor in the HTML of the form processing page where you want to display a "thank you" message and tax notice to customers. After the thank you message, enter the beginning mgiIf tag, the target parameter, additional required and optional parameters for the target, and the ending mgiIf tag.
 
In the target parameter, enter the source of the information for the comparison (Browser, Client, Cookie, Date, Field, Post Argument, Referrer, or Variable). In this example, the source of the comparison is a form field (also known as a post argument). Specific required and optional parameters are associated with each target (see the tag reference for a complete list). For the "field" target, the "name" parameter and the "value" parameter are required. In the name parameter, enter the name of the form field that is the source of the comparison (e.g., "State"). In the value parameter, enter the value to compare (e.g., "North Carolina"). Enter the ending mgiIf tag. Between the beginning and ending mgiIf tags (the body), enter the action to perform when the comparison is true. Enter the message, including HTML, "<B>Note:</B> A 6% sales tax will be added to your order total."
<mgiIf target="Field" name="State" value="North Carolina">
<B>Note:</B> A 6% sales tax will be added to your order total.
</mgiIf>

Step 4: Save the form processing page.

Save the changes you have made to the form processing page.

Step 5: FTP the order form and form processing page to the web server running MGI.

Upload the order form and form processing page to the web server using an FTP program.

Step 6: Complete and submit the form.

Access the order form in a web browser. Complete and submit the order form. When you enter "North Carolina" in the "state" field of the order form, the following message is displayed:
Note: A 6% sales tax will be added to your order total.
When you enter any other state in the "state" field of the order form, no message is displayed.

[Return to the Using If, Then, Else Comparisons Menu]


[User Guide Main Menu] [Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]