Checkbox fields differ from radio buttons in that they are inherently multi-value devices so we can't use a simple scalar EWD Session variable. Instead we use a special EWD Session array known as the Selected array. Checkboxes are handled in EWD as follows. Let's imagine we have an HTML form in our EWD page with the following radio button field:

   Red: <input type="checkbox" name="colour" value="r" /><br>
   Blue: <input type="checkbox" name="colour" value="b" /><br>
   Green: <input type="checkbox" name="colour" value="g" /><br>

To pre-check value(s) when the page is displayed, in the page's pre-page script, you instantiate the corresponding values in the Selected array, mapping via the field's name, eg

  d clearSelected^%zewdAPI("colour",sessid)
  d addToSelected^%zewdAPI("colour","r",sessid)
  d addToSelected^%zewdAPI("colour","g",sessid)

In this case the Red and Green checkboxes will be checked when the page is displayed. Note the way the Selected array is initially cleared down to prevent any previously assigned values from erroneously being displayed. Of course, typically you'll determine the value(s) to pre-check (if any) based on information retrieved from the database.

When the form is submitted, the checked values are automatically copied back to the Selected Array by EWD. The form's Action Script can simply check whether or not a value is in the matching Selected array, eg:

  i $$isSelected^%zewdAPI("colour","b" sessid) d ##class(ewd.examples).doIt("blue")

Alternatively you can merge the Selected array to a local array and process the value(s) appropriately, eg:

  d getCheckboxValues^%zewdAPI("colour",.colours,sessid)

In this example, if the form had been submitted with Red and Blue checked, the colours array would contain:

  colours("r")="r"
  colours("b")="b"

Click the Enterprise Web Developer/Examples tab for worked examples.