1HTMLDocument.addSelectElement(K3akyaayam)odule reHfTeMrLeDnocceument.addSelectElement(3kaya)
2
3
4

NAME

6       HTMLDocument::addSelectElement - Adds a selection box
7

SYNOPSIS

9       ElementTree  addSelectElement(  ElementTree  block,  String  name,  Int
10       ssize, [Pair<String, [SelectOption]> ] optgroups )
11

ARGUMENTS

13       parent The parent element
14
15       name The name of the input. Remember that names starting  with  "kaya_"
16       may  be  used  by  the  Kaya  standard  library  and should not be used
17       directly by applications.
18
19       ssize The size of the select element. If this is zero, the select  ele‐
20       ment will only allow one option to be selected at any one time. If this
21       is one or more, the select element will allow multiple  options  to  be
22       selected,  and  suggest  to  the browser that this many options be dis‐
23       played simultaneously.
24
25       optgroups The options to select from
26

DESCRIPTION

28       Adds a selection box to a form. The optgroups parameter is  a  list  of
29       pairs.  The  first  element of the pair is the 'heading' for the option
30       group, and the second element is a list of options in that  group.  For
31       most simple selectors, a single option group with no heading (the empty
32       string) is sufficient.
33
34
35    options = [
36        SelectOption("Express delivery","1",true),
37        SelectOption("Standard delivery","2",false),
38        SelectOption("Slow delivery","3",false)
39    ];
40    sel = addSelectElement(fieldset,"choice",0,[("",options)]);
41    /* // produces
42    <select>
43      <option value='1' selected='selected'>Express delivery</option>
44      <option value='2'>Standard delivery</option>
45      <option value='3'>Slow delivery</option>
46    </select>
47    */
48
49       Using multiple groups of options is useful for larger select  elements,
50       where it can make the form clearer.
51
52
53    singles = ["A1","A2","B5"];
54    twins = ["A4","C2"];
55    doubles = ["A7","C1","C3"];
56    sopts = [];
57    topts = [];
58    dopts = [];
59    for s in singles {
60        push(sopts,SelectOption(s,s,false);
61    }
62    for t in twins {
63        push(topts,SelectOption(s,s,false);
64    }
65    for d in doubles {
66        push(dopts,SelectOption(s,s,false);
67    }
68    options = [
69        ("Single rooms",sopts),
70        ("Twin rooms",topts),
71        ("Double rooms",dopts)
72    ];
73    sel = addSelectElement(roombooker,"room",0,options);
74
75       Select  elements allowing multiple options to be selected have very bad
76       usability in most browsers -  it  is  often  better  to  use  HTMLDocu‐
77       ment.addOptionList  (3kaya)  to  generate  a set of checkboxes instead.
78       Whichever method you use for multiple selection, remember that you need
79       to  use WebCommon.incomingData (3kaya) to correctly retrieve the selec‐
80       tions from the user's form submission.
81

AUTHORS

83       Kaya  standard  library  by  Edwin  Brady,  Chris  Morris  and   others
84       (kaya@kayalang.org). For further information see http://kayalang.org/
85

LICENSE

87       The  Kaya  standard  library  is free software; you can redistribute it
88       and/or modify it under the terms  of  the  GNU  Lesser  General  Public
89       License  (version  2.1  or  any later version) as published by the Free
90       Software Foundation.
91
93       HTMLDocument.SelectOption (3kaya)
94       HTMLDocument.addFieldset (3kaya)
95       HTMLDocument.addLabelledSelect (3kaya)
96       HTMLDocument.addLazySelect (3kaya)
97       HTMLDocument.addOptionList (3kaya)
98       HTMLDocument.addTextarea (3kaya)
99       HTMLDocument.addTextInput (3kaya)
100
101
102
103Kaya                             December 2H0T1M0LDocument.addSelectElement(3kaya)
Impressum