aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dijit/tests/form/test_CheckBox.html
blob: 43582704273e9d58780e3192d36f0b34a23c8392 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>CheckBox Widget Demo</title>

	<style type="text/css">
		@import "../../../dojo/resources/dojo.css";
		@import "../css/dijitTests.css";

		label { margin-right: 0.80em; }
	</style>
	
	<script type="text/javascript" src="../../../dojo/dojo.js"
		djConfig="isDebug: true, parseOnLoad: true"></script>
	<script type="text/javascript" src="../_testCommon.js"></script>

	<script type="text/javascript">
		dojo.require("dijit.form.CheckBox");
		dojo.require("dojo.parser");	// find widgets

		function outputValues(form){
			var str = "";
			for(var i=0;i<form.elements.length;i++){
				var e = form.elements[i];
				if(e.type=="submit") break;
				if(e.checked){
					str += "submit: name="+e.name+" id="+e.id+" value="+e.value+ "<br>";
				}
			}
			dojo.byId("result").innerHTML = str;
			return false;
		}

		function reportChecked(checked) {
			dojo.byId("oncheckedoutput").innerHTML = checked;
		}

		function reportValueChanged(value) {
			dojo.byId("onvaluechangedoutput").innerHTML = value;
		}

		dojo.addOnLoad(function(){
			var params = {id: "cb6", name: "cb6"};
			var widget = new dijit.form.CheckBox(params, dojo.byId("checkboxContainer"));
			widget.setAttribute('checked', true);
		});
	</script>
</head>
<body>
	<h1 class="testTitle">Dijit CheckBox Test</h1>
	<p>
	Here are some checkboxes.  Try clicking, and hovering, tabbing, and using the space bar to select:
	</p>
	<!--  <form onSubmit="return outputValues(this);"> -->
	<!--    to test form submission, you'll need to create an action handler similar to
		http://www.utexas.edu/teamweb/cgi-bin/generic.cgi -->
	<form>
		<input type="checkbox" name="cb0" id="cb0" />
			<label for="cb0">cb0: Vanilla (non-dojo) checkbox (for comparison purposes)</label>
		<br>
		<input type="checkbox" name="cb1" id="cb1" value="foo" dojoType="dijit.form.CheckBox" onClick="console.log('clicked cb1')">
			<label for="cb1">cb1: normal checkbox, with value=foo, clicking generates console log messages</label>
		<br>
		<input onChange="reportChecked" type="checkbox" name="cb2" id="cb2" dojoType="dijit.form.CheckBox" checked="checked"/>
			<label for="cb2">cb2: normal checkbox, initially turned on.</label>
			<span>"onChange" handler updates: [<span id="oncheckedoutput"></span>]</span>
		<br>
		<input type="checkbox" name="cb3" id="cb3" dojoType="dijit.form.CheckBox" disabled="disabled">
			<label for="cb3">cb3: disabled checkbox</label>
		<br>
		<input type="checkbox" name="cb4" id="cb4" dojoType="dijit.form.CheckBox" disabled="disabled" checked="checked"/>
			<label for="cb4">cb4: disabled checkbox, turned on</label>
		<br>
		<input type="checkbox" name="cb5" id="cb5" />
			<label for="cb5">cb5: Vanilla (non-dojo) checkbox (for comparison purposes)</label>
		<br>
		<div id="checkboxContainer"></div>
			<label for="cb6">cb6: instantiated from script</label>
		<br>
		<input onChange="reportValueChanged" type="checkbox" name="cb7" id="cb7" dojoType="dijit.form.CheckBox">
			<label for="cb7">cb7: normal checkbox.</label>
			<input type="button" onclick='dijit.byId("cb7").setAttribute("disabled",true);' value="disable" />
			<input type="button" onclick='dijit.byId("cb7").setAttribute("disabled",false);' value="enable" />
			<input type="button" onclick='dijit.byId("cb7").setValue("fish");' value='set value to "fish"' />
			<input type="button" onclick='dijit.byId("cb7").reset();' value='Reset value+checked' />
			<span>"onChange" handler updates: [<span id="onvaluechangedoutput"></span>]</span>
		<br>
	<p>
	Here are some radio buttons.  Try clicking, and hovering, tabbing, and arrowing
	</p>
		<p>
			<span>Radio group #1:</span>
			<input type="radio" name="g1" id="g1rb1" value="news" dojoType="dijit.form.RadioButton">
			<label for="g1rb1">news</label>
			<input type="radio" name="g1" id="g1rb2" value="talk" dojoType="dijit.form.RadioButton" checked="checked"/>
			<label for="g1rb2">talk</label>
			<input type="radio" name="g1" id="g1rb3" value="weather" dojoType="dijit.form.RadioButton" disabled="disabled"/>
			<label for="g1rb3">weather</label>
		</p>
		<p>
			<span>Radio group #2: (no default value, and has breaks)</span><br>
			<input type="radio" name="g2" id="g2rb1" value="top40" dojoType="dijit.form.RadioButton"/>
			<label for="g2rb1">top 40</label><br>
			<input type="radio" name="g2" id="g2rb2" value="oldies" dojoType="dijit.form.RadioButton"/>
			<label for="g2rb2">oldies</label><br>
			<input type="radio" name="g2" id="g2rb3" value="country" dojoType="dijit.form.RadioButton"/>
			<label for="g2rb3">country</label><br>
			(Note if using keyboard: tab to navigate, and use arrow or space to select)
		</p>
		<p>
			<span>Radio group #3 (native radio buttons):</span>
			<input type="radio" name="g3" id="g3rb1" value="rock"/>
			<label for="g3rb1">rock</label>
			<input type="radio" name="g3" id="g3rb2" value="jazz" disabled="disabled"/>
			<label for="g3rb2">jazz</label>
			<input type="radio" name="g3" id="g3rb3" value="classical" checked="checked"/>
			<label for="g3rb3">classical</label>
		</p>
		<input type="submit" />
	</form>

	<!-- <p>Submitted data:</p>
	<div id="result"></div>
	 -->
</body>
</html>