XForms/Range

NOTE
These examples do not appear to work with the FireFox 3 XForms addition. Sliders are hidden with XSLTForms (r406).

Motivation
You want to use a range control or "slider" to set a numeric value in your form.

Selecting from a continuous range of values
The range is a control that is part of the XForms specification. It allows the user to select a numeric value from a range of values without using the keyboard. This is ideal for instructors that use interactive learning environments such as a SmartBoard.

The XForms range has four attributes:
 * start - the lower bound of the range
 * end - the upper bound of the range
 * step - the increment of output change
 * incremental - true if the form should send continuous values to the model or false otherwise. The default is false.

These attributes MUST be bound to an element that has a numeric datatype. To do this you must add the following bind statements to your model:

User Interface
There are three range controls in this application. The value of the range is on the right side.



Link to XForms Application
Basic Range

Ranges Using Binds

Sample User Interface
      Data1:     Value=  

 Data2:  </xf:range> <xf:output ref="data2"> <xf:label> Value= </xf:label> </xf:output>

<xf:range ref="data3" start="1" end="100" step="5" incremental="true"> <xf:label>Data3: </xf:label> </xf:range> <xf:output ref="data3"> <xf:label> Value= </xf:label> </xf:output>

Testing
Select one of the three range controls with the mouse. Drag the value to the right or left. You should notice that the values at the right also are updated.

The first control just selects decimals from 1 to 5. The second uses the step to return only integers. The last has a range of 1 to 100 in increments of 5. Note that the value is 66 and you cannot set a value from 62 to 65.

Discussion
The upper and lower values of the range control can also be set directly in the model. XML Schema provides a minValue and a maxValue that can be used to adjust the range control limits.

W3C Specification
Here is the specification from the W3C web site: W3C range specification