]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dijit/tests/form/test_CheckBox.html
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dijit / tests / form / test_CheckBox.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2         "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5         <title>CheckBox Widget Demo</title>
6
7         <style type="text/css">
8                 @import "../../../dojo/resources/dojo.css";
9                 @import "../css/dijitTests.css";
10
11                 label { margin-right: 0.80em; }
12         </style>
13         
14         <script type="text/javascript" src="../../../dojo/dojo.js"
15                 djConfig="isDebug: true, parseOnLoad: true"></script>
16         <script type="text/javascript" src="../_testCommon.js"></script>
17
18         <script type="text/javascript">
19                 dojo.require("dijit.form.CheckBox");
20                 dojo.require("dojo.parser");    // find widgets
21
22                 function outputValues(form){
23                         var str = "";
24                         for(var i=0;i<form.elements.length;i++){
25                                 var e = form.elements[i];
26                                 if(e.type=="submit") break;
27                                 if(e.checked){
28                                         str += "submit: name="+e.name+" id="+e.id+" value="+e.value+ "<br>";
29                                 }
30                         }
31                         dojo.byId("result").innerHTML = str;
32                         return false;
33                 }
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.addOnLoad(function(){
44                         var params = {id: "cb6", name: "cb6"};
45                         var widget = new dijit.form.CheckBox(params, dojo.byId("checkboxContainer"));
46                         widget.setAttribute('checked', true);
47                 });
48         </script>
49 </head>
50 <body>
51         <h1 class="testTitle">Dijit CheckBox Test</h1>
52         <p>
53         Here are some checkboxes.  Try clicking, and hovering, tabbing, and using the space bar to select:
54         </p>
55         <!--  <form onSubmit="return outputValues(this);"> -->
56         <!--    to test form submission, you'll need to create an action handler similar to
57                 http://www.utexas.edu/teamweb/cgi-bin/generic.cgi -->
58         <form>
59                 <input type="checkbox" name="cb0" id="cb0" />
60                         <label for="cb0">cb0: Vanilla (non-dojo) checkbox (for comparison purposes)</label>
61                 <br>
62                 <input type="checkbox" name="cb1" id="cb1" value="foo" dojoType="dijit.form.CheckBox" onClick="console.log('clicked cb1')">
63                         <label for="cb1">cb1: normal checkbox, with value=foo, clicking generates console log messages</label>
64                 <br>
65                 <input onChange="reportChecked" type="checkbox" name="cb2" id="cb2" dojoType="dijit.form.CheckBox" checked="checked"/>
66                         <label for="cb2">cb2: normal checkbox, initially turned on.</label>
67                         <span>"onChange" handler updates: [<span id="oncheckedoutput"></span>]</span>
68                 <br>
69                 <input type="checkbox" name="cb3" id="cb3" dojoType="dijit.form.CheckBox" disabled="disabled">
70                         <label for="cb3">cb3: disabled checkbox</label>
71                 <br>
72                 <input type="checkbox" name="cb4" id="cb4" dojoType="dijit.form.CheckBox" disabled="disabled" checked="checked"/>
73                         <label for="cb4">cb4: disabled checkbox, turned on</label>
74                 <br>
75                 <input type="checkbox" name="cb5" id="cb5" />
76                         <label for="cb5">cb5: Vanilla (non-dojo) checkbox (for comparison purposes)</label>
77                 <br>
78                 <div id="checkboxContainer"></div>
79                         <label for="cb6">cb6: instantiated from script</label>
80                 <br>
81                 <input onChange="reportValueChanged" type="checkbox" name="cb7" id="cb7" dojoType="dijit.form.CheckBox">
82                         <label for="cb7">cb7: normal checkbox.</label>
83                         <input type="button" onclick='dijit.byId("cb7").setAttribute("disabled",true);' value="disable" />
84                         <input type="button" onclick='dijit.byId("cb7").setAttribute("disabled",false);' value="enable" />
85                         <input type="button" onclick='dijit.byId("cb7").setValue("fish");' value='set value to "fish"' />
86                         <input type="button" onclick='dijit.byId("cb7").reset();' value='Reset value+checked' />
87                         <span>"onChange" handler updates: [<span id="onvaluechangedoutput"></span>]</span>
88                 <br>
89         <p>
90         Here are some radio buttons.  Try clicking, and hovering, tabbing, and arrowing
91         </p>
92                 <p>
93                         <span>Radio group #1:</span>
94                         <input type="radio" name="g1" id="g1rb1" value="news" dojoType="dijit.form.RadioButton">
95                         <label for="g1rb1">news</label>
96                         <input type="radio" name="g1" id="g1rb2" value="talk" dojoType="dijit.form.RadioButton" checked="checked"/>
97                         <label for="g1rb2">talk</label>
98                         <input type="radio" name="g1" id="g1rb3" value="weather" dojoType="dijit.form.RadioButton" disabled="disabled"/>
99                         <label for="g1rb3">weather</label>
100                 </p>
101                 <p>
102                         <span>Radio group #2: (no default value, and has breaks)</span><br>
103                         <input type="radio" name="g2" id="g2rb1" value="top40" dojoType="dijit.form.RadioButton"/>
104                         <label for="g2rb1">top 40</label><br>
105                         <input type="radio" name="g2" id="g2rb2" value="oldies" dojoType="dijit.form.RadioButton"/>
106                         <label for="g2rb2">oldies</label><br>
107                         <input type="radio" name="g2" id="g2rb3" value="country" dojoType="dijit.form.RadioButton"/>
108                         <label for="g2rb3">country</label><br>
109                         (Note if using keyboard: tab to navigate, and use arrow or space to select)
110                 </p>
111                 <p>
112                         <span>Radio group #3 (native radio buttons):</span>
113                         <input type="radio" name="g3" id="g3rb1" value="rock"/>
114                         <label for="g3rb1">rock</label>
115                         <input type="radio" name="g3" id="g3rb2" value="jazz" disabled="disabled"/>
116                         <label for="g3rb2">jazz</label>
117                         <input type="radio" name="g3" id="g3rb3" value="classical" checked="checked"/>
118                         <label for="g3rb3">classical</label>
119                 </p>
120                 <input type="submit" />
121         </form>
122
123         <!-- <p>Submitted data:</p>
124         <div id="result"></div>
125          -->
126 </body>
127 </html>