How to Create a Decision Form

Forio Broadcast makes it easy to create a decision page.  You can use a "Submit" button to save a decision and advance to the next round.  If you click a hyperlink instead of submitting the form, Broadcast will automatically save the decisions for later (as long as the hyperlink uses a #Link directive).  And if you set the decision properties DecisionMin and DecisionMax in the model, Broadcast will automatically check that the decision is within the specified range.

To create a simple decision form, follow these five steps:

Step 1: Add JavaScript

In your HTML, immediately following the <head> tag, add the following:

 

<script type="text/javascript" src="/tools/forio.js"></script>
 

 

This loads JavaScript routines into your HTML pages to handle simulation navigation and form validation.

Step 2: Create a Form

Name the form Decisions. Set the form method to "post". Set the action to the web page you would like the user to link to after the submit button is pressed.

 

<form name="Decisions" method="post" action="advance.htm">
 

 

Forms with decisions on them must be named Decisions and must use the "post" method to get Broadcast to transfer user decisions to the simulation. action="advance.htm" takes the user to the page advance.htm after the decisions have been posted to the simulation.  

Step 3: Create a Text Box

Name the text field D_varname where "varname" is the name of your user decision.  Set the rest of the text field as follow.

 

<input type="text" name="D_Price X5" value="$Values.get('Price X5').DecisionFormatted"
          onBlur="#Validate($Values.get('Price X5'))">
 

 

This name of the input field-- "D_Price X5"-- tells Forio Broadcast what variable the decision should apply to.  The value attribute-- "$Values.get('Price X5').DecisionFormatted"-- is the value of the decision displayed when the page is loaded.  The onBlur is a JavaScript event that is called when the mouse leaves the text box.  By setting this to "#Validate($Values.get('Price X5"))" we ensure that the user-entered value is checked that it is within the appropriate range.

A shorter way of doing this is to use the built-in macro directive #TextDecision (which will insert the same results into the file as the more detailed statement above).  But you may prefer the longer statement as it is more customizable and will show up better in WYSIWYG HTML editors.

 

#TextDecision("Price X5")
 

 

Step 4: Create a Hidden FD_action Field.

Name it FD_action and set its value to step

 

<input type="hidden" name="FD_action" value="step">
 

 

This tells Broadcast to advance the simulation one time step when the submit decisions button is pressed.

Step 5: Create a Submit Button

Create a submit button with the value Submit Decisions

 

<input type="submit" value="Submit Decisions">
 

 

This lets your users press 'Submit Decisions' after they have made their decisions.  

 

Decisions Example

Below is an example of using all five steps to make a decision and advance the simulation.

 

<html>
<head>
<title>Forio Broadcast></title>
<script type="text/javascript" src="/tools/forio.js"></script>
</head>
 

<body>
## Show the current simulation time

The current time is $Run.SimTime<BR><BR>

## Link to a simulation
<A HREF="#Link('result.htm')"> Go To Results </A><BR><BR>

## Exit the simulation
<A HREF="exit.htm"> Exit simulation </A><BR>

## Submit and validate a decision and advance the simulation
<form name="Decisions" method="post" action="advance.htm">
<p>$Values.get('Price').Label
<input type="text" name="D_Price" value="$Values.get('Price').DecisionFormatted" onBlur="#Validate($Values.get('Price'))"></p>
<input type="hidden" name="FD_action" value="step">
<p><input type="submit" value="Submit Decisions"></p>
</form>

</body>
</html>
 

 

The output from this HTML and FML creates the following web page: