Kaya 0.5.2 reference for HTMLDocument::addOptionList

List of functions and data types in HTMLDocument

ElementTree addOptionList(ElementTree parent, String legend, String iname, [SelectOption] options, Bool allowmultiple=true)

Arguments

Usage

Adds a set of checkboxes or radio buttons to a form. The meaning of the parameters is very similar or identical to the similar parameters for addLabelledSelect, but the appearance is very different. If the number of options is not large, this is generally considerably easier to use than a selection drop-down, although it does take up much more screen space.

When using this function to generate radio buttons, you should ensure that one of the options is initially selected, as browser behaviour when no option is selected is variable and often causes problems. You may need to add a "no option selected" radio button for initial selection in some circumstances.

options = [
    SelectOption("Express delivery","1",true),
    SelectOption("Standard delivery","2",false),
    SelectOption("Slow delivery","3",false)
];
sel = addLabelledSelect(fieldset,"Select a delivery speed","choice",
                        options,false);
/* // produces 
<fieldset><legend>Select a delivery speed</legend>
  <div><input type='checkbox' name='choice' value='1' id='Kay1' 
                    checked='checked'>
    <label for='Kay1'>Express delivery</label></div>
  <div><input type='checkbox' name='choice' value='2' id='Kay2'>
    <label for='Kay2'>Standard delivery</label></div>
  <div><input type='checkbox' name='choice' value='3' id='Kay3'>
    <label for='Kay3'>Slow delivery</label></div>
</fieldset>
*/ // exact markup may vary slightly to keep IDs unique in the document

Related

kaya@kayalang.org | Last modified 29 November 2011 | Supported by Durham CompSoc | Powered by Kaya