How do I configure conditional responses in FormMail?

In this article, FormMail is configured to display different responses based on conditionals specified by the user.

In this example, FormMail is configured to display different  responses based on selections made by the submitter. View demo.

Form

<html>
<head><title>Just testing</title></head>
<body>

<form method="post" action="http://www.uic.edu/htbin/cgiwrap/bin/formmail/FormMail/depts/accc/forms/formmail/example-2.txt">
<h1>Example of FormMail 3.0</h1>
This example shows the use of conditional responses.
<p>
What's your favorite color? <input type=text name="color">
<p>
Is the sky blue?
<input type=radio name="sky" value="yes">Yes
<input type=radio name="sky" value="no">No
<p>
Select a number:
<select single name="number">
<option> 1234
<option> 123543
<option> 4567
</select>

<hr>
<input type="submit" value="Submit the form">
</form>
</body>
</html>

Configuration file

<!DOCTYPE form SYSTEM 'FormMail-3.0.dtd'>
<form name="example2" >

 <!-- No validation checking is done, although it could have been.
      Conditional responses are below -->
  
 <!-- This prevents any mail being sent for this example -->

<mail name="mail2" nomail>


 <!-- Here's the html response header 
      Note that the full html page is generated, including
      the <html>...</html> tags 
  -->

<response name="r0" >
<![CDATA[
<html><head><title>Test</title></head><body>
<h1> Thank You for Submitting your Info</h1>
]]>
</response>

 <!-- conditional responses to various answers -->

<response name="red" if="$color eq red or $color eq orange" >
<![CDATA[
<p> Yes, I like $color, too.
]]>
</response>

<response name="blue" if="$color eq blue" >
<![CDATA[
<p> That's ok, but I don't care much for blue.
]]>
</response>

<response name="other" if="$color ne blue and $color ne red and $color ne orange" >
<![CDATA[
<p> Well, I suppose $color is ok.
]]>
</response>

<response name="sky-yes" if="$sky eq yes" >
<![CDATA[
<p> Yes! Love that blue sky!
]]>
</response>

<response name="sky-no" if="$sky eq no" >
<![CDATA[
<p> Sky not blue? You live in Chicago in the winter?
You gotta get out more often!
]]>
</response>

<response name="numone" if="$number pre 1" >
<![CDATA[
<p> Your number started with 1.
]]>
</response>

<response name="numone" if="$number npre 1" >
<![CDATA[
<p> Your number didn't start with 1.
]]>
</response>

 <!-- And finally, the end!  -->

<response name="r2" >
<![CDATA[
</body></html>
 ]]>
</response>


</form>



Keywords:code, response, reply, mail   Doc ID:91738
Owner:Radhika R.Group:University of Illinois at Chicago ACCC
Created:2019-05-15 08:29 CDTUpdated:2019-06-13 11:53 CDT
Sites:University of Illinois at Chicago ACCC
Feedback:  0   0