< XForms



You have a boolean true/false value and want an input control to have a simple checkbox for a yes/no or true/false answer.


We will use a standard input control but use the bind statement to bind the instance to a boolean datatype. We will do this in two ways, one using a bind without an ID and using the bind with an id so that we can reference the bind statement.

Note that checkboxes can also be demonstrated by using the xf:select control. But in that case a series of space-delimited values is stored in the value associated with the control.

Screen ImageEdit

Boolean Checkbox Using Input Control

Link to XForms ApplicationEdit

Sample ProgramEdit

      <title>XForms Checkbox Demo</title>
      <style type="text/css"><![CDATA[body {font-family: Helvetica, sans-serif;}]]>
         <!-- load the module test data into the model -->
         <xf:instance xmlns="">
         <!-- Here is where we indicate the datatypes of the instance variables -->
         <xf:bind ref="bool1" type="xs:boolean"  />
         <xf:bind id="bool2" ref="bool2" type="xs:boolean"  />
      <h1>XForms Checkbox Demo</h1>
      <xf:input ref="bool1">
         <xf:label>Bool 1: </xf:label>
      <br />
      <!-- use a named binding -->
      <xf:input bind="bool2">
         <xf:label>Bool 2: </xf:label>
      <br />
      <xf:output ref="bool1">
         <xf:label>Bool 1: </xf:label>
      <br />
      <xf:output bind="bool2">
         <xf:label>Bool 2: </xf:label>

Next Page: Select1 | Previous Page: Textarea with style

Home: XForms