Debian Codegraph @

dijit/tests/form/test_CheckBox.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5 <title>CheckBox Widget Demo</title>
6
7 <style type="text/css">
8 @import "../../themes/claro/document.css";
9 @import "../css/dijitTests.css";
10
11 label { margin-right: 0.80em; }
12 </style>
13
14
15 <!-- required: the default dijit theme: -->
16 <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/>
17
18 <!-- required: dojo.js -->
19 <script type="text/javascript" src="../../../dojo/dojo.js"
20 data-dojo-config="isDebug: true, parseOnLoad: true"></script>
21
22 <!-- only needed for alternate theme testing: -->
23 <script type="text/javascript" src="../_testCommon.js"></script>
24
25 <script type="text/javascript">
26 dojo.require("dijit.form.CheckBox");
27 dojo.require("dijit.form.RadioButton");
28 dojo.require("dijit.form.Form");
29
30 function defaultSubmitHandler(values){
31 console.debug('actual submitted values: ' + dojo.toJson(values));
32 }
33 submittedValues = defaultSubmitHandler;
34
35 function reportChecked(checked){
36 dojo.byId("oncheckedoutput").innerHTML = checked;
37 }
38
39 function reportValueChanged(value){
40 dojo.byId("onvaluechangedoutput").innerHTML = value;
41 }
42
43 dojo.ready(function(){
44 var params = {id: "cb6", name: "cb6", checked: true };
45 new dijit.form.CheckBox(params, "cb6");
46
47 new dijit.form.RadioButton({
48 checked: true,
49 value: "tea",
50 name: "drink"
51 }, "g4rb1");
52 new dijit.form.RadioButton({
53 value: "coffee",
54 name: "drink"
55 }, "g4rb2");
56
57 });
58 </script>
59 </head>
60 <body class="claro" role="main">
61
62 <h1 class="testTitle">Dijit CheckBox Test</h1>
63 <p>
64 Here are some checkboxes. Try clicking, and hovering, tabbing, and using the space bar to select:
65 </p>
66 <!-- to test form submission, you'll need to create an action handler similar to
67 http://www.utexas.edu/teamweb/cgi-bin/generic.cgi -->
68 <form id="myForm" data-dojo-type="dijit/form/Form" data-dojo-props='action:"../formAction.html", method:"", target:"formSubmitIframe"'>
69 <input type="checkbox" id="cb0" checked/>
70 <label for="cb0">cb0: Vanilla (non-dojo) checkbox (for comparison purposes)</label>
71 <br>
72 <input id="cb1" data-dojo-id="cb1" data-dojo-type="dijit/form/CheckBox" data-dojo-props='name:"cb1", value:"foo", onClick:function(){ console.log("clicked cb1") }'/>
73 <label for="cb1">cb1: normal checkbox, with value=foo, clicking generates console log messages</label>
74 <button type=button onclick="alert(dijit.byId('cb1').get('value'));">get('value')</button>
75 <br>
76 <input id="cb2" data-dojo-type="dijit/form/CheckBox" data-dojo-props='onChange:reportChecked, name:"cb2", checked:true'/>
77 <label for="cb2">cb2: normal checkbox, with default value, initially turned on.</label>
78 <span>"onChange" handler updates: [<span id="oncheckedoutput"></span>]</span>
79 <button type=button onclick="alert(dijit.byId('cb2').get('value'));">get('value')</button>
80 <br>
81 <input id="cb3" data-dojo-type="dijit/form/CheckBox" data-dojo-props='name:"cb3", disabled:true'/>
82 <label for="cb3">cb3: disabled checkbox</label>
83 <br>
84 <input id="cb4" data-dojo-type="dijit/form/CheckBox" data-dojo-props='name:"cb4", readOnly:true, checked:true, value:"" '/><!-- blank value => "on" -->
85 <label for="cb4">cb4: readOnly checkbox, turned on</label>
86 <br>
87 <input id="cb5" data-dojo-type="dijit/form/CheckBox" data-dojo-props='name:"cb5", value:"", onClick:function(){ console.log("clicked cb5"); }'/>
88 <label for="cb5">cb5: normal checkbox, with specified value="", clicking generates console log messages</label>
89 <button type=button onclick="alert(dijit.byId('cb5').get('value'));">get('value')</button>
90 <br>
91 <input id="cb6"/>
92 <label for="cb6">cb6: instantiated from script</label>
93 <br>
94 <input id="cb7" data-dojo-type="dijit/form/CheckBox" data-dojo-props='onChange:reportValueChanged, name:"cb7" '/>
95 <label for="cb7">cb7: normal checkbox.</label>
96 <input type="button" onclick='dijit.byId("cb7").set("disabled",true);' value="disable" />
97 <input type="button" onclick='dijit.byId("cb7").set("disabled",false);' value="enable" />
98 <input type="button" onclick='dijit.byId("cb7").set("value", "fish");' value='set value to "fish"' />
99 <input type="button" onclick='dijit.byId("cb7").reset();' value='Reset value+checked' />
100 <span>"onChange" handler updates: [<span id="onvaluechangedoutput"></span>]</span>
101 <br>
102 <p>
103 Here are some radio buttons. Try clicking, and hovering, tabbing, and arrowing
104 </p>
105 <p>
106 <span>Radio group #1:</span>
107 <input id="g1rb1" data-dojo-type="dijit/form/RadioButton" data-dojo-props='name:"g[1]", value:"news" '/>
108 <label for="g1rb1">news</label>
109 <input id="g1rb2" data-dojo-type="dijit/form/RadioButton" data-dojo-props='name:"g[1]", checked:true'/><!-- no value => "on" -->
110 <label for="g1rb2">talk</label>
111 <input id="g1rb3" data-dojo-type="dijit/form/RadioButton" data-dojo-props='name:"g[1]", value:"", disabled:true'/><!-- blank value => "" -->
112 <label for="g1rb3">weather</label>
113 <input type="button" id="enableWeatherButton" onclick='dijit.byId("g1rb3").set("disabled",false);' value="enable weather" />
114 <input type="button" onclick='dijit.byId("g1rb3").set("disabled",true);' value="disable weather" />
115 </p>
116 <p>
117 <span>Radio group #2: (no default value, and has breaks)</span><br>
118 <input id="g2rb1" data-dojo-type="dijit/form/RadioButton" data-dojo-props='name:"g2", value:"top40" '/>
119 <label for="g2rb1">top 40</label><br>
120 <input id="g2rb2" data-dojo-type="dijit/form/RadioButton" data-dojo-props='name:"g2", value:"oldies" '/>
121 <label for="g2rb2">oldies</label><br>
122 <input id="g2rb3" data-dojo-type="dijit/form/RadioButton" data-dojo-props='name:"g2", value:"country" '/>
123 <label for="g2rb3">country</label><br>
124 (Note if using keyboard: tab to navigate, and use arrow or space to select)
125 </p>
126 <button data-dojo-type="dijit/form/Button" data-dojo-props='type:"submit", value:"Submit"'>Submit</button>
127 <button data-dojo-type="dijit/form/Button" data-dojo-props='type:"reset"'>HTML Reset</button>
128 </form>
129
130 <p>
131 <span>Radio group #3 (native radio buttons):</span>
132 <input type="radio" name="g3" id="g3rb1" value="rock"/>
133 <label for="g3rb1">rock</label>
134 <input type="radio" name="g3" id="g3rb2" value="jazz" disabled="disabled"/>
135 <label for="g3rb2">jazz</label>
136 <input type="radio" name="g3" id="g3rb3" value="classical" checked="checked"/>
137 <label for="g3rb3">classical</label>
138 </p>
139
140 <div style='border:1px solid gray;'>
141 These 6 radio buttons have the same name but are in separate forms so they can be selected independently.
142 <form>
143 1:
144 <input id='b1' data-dojo-type="dijit/form/RadioButton" data-dojo-props='name:"a1", value:"1"'/><label for='b1'>b1</label>
145 <input id='b2' data-dojo-type="dijit/form/RadioButton" data-dojo-props='name:"a1", value:"2"'/><label for='b2'>b2</label>
146 </form>
147 <form>
148 2:
149 <input id='c1' data-dojo-type="dijit/form/RadioButton" data-dojo-props='name:"a1", value:"1"'/><label for='c1'>c1</label>
150 <input id='c2' data-dojo-type="dijit/form/RadioButton" data-dojo-props='name:"a1", value:"2"'/><label for='c2'>c2</label>
151 </form>
152 <div>
153 3:
154 <input id='d1' data-dojo-type="dijit/form/RadioButton" data-dojo-props='name:"a1", value:"1"'/><label for='d1'>d1</label>
155 <input id='d2' data-dojo-type="dijit/form/RadioButton" data-dojo-props='name:"a1", value:"2"'/><label for='d2'>d2</label>
156 </div>
157 </div>
158
159 <div>
160 <span>Programmatic radio buttons:</span>
161 <form id="radioForm">
162 <input type="radio" name="drink" id="g4rb1" checked value="tea"/> <label for="g4rb1">Tea</label> <br />
163 <input type="radio" name="drink" id="g4rb2" checked value="coffee"/> <label for="g4rb2">Coffee</label> <br />
164 </form>
165 </div>
166 <iframe name="formSubmitIframe" src="about:blank" onload="if(this.values)submittedValues(this.values)" style="display:none;"></iframe>
167 </body>
168 </html>