-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_checkmate.html
57 lines (49 loc) · 1.85 KB
/
demo_checkmate.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Checkmate jQuery Plugin - Mirror Checkbox Selections</title>
<!-- js -->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script tpe="text/javascript" src="checkmate.js"></script>
<script>
$(document).ready(function() {
$('input.control').click(function(){
$(this).checkmate();
});
});
</script>
</head>
<body>
<p><strong>This is handy to mirror a fake set of checkbox selection attributes to other inputs.</strong><br />
<em>For instance, to manipulate a set of form inputs from outside the form.</em></p>
<p>Click any checkbox in the controller set. The related checkbox in the target set should mirror it's status.</p>
</ol>
Controller:
<input type="checkbox" val="1" class="control" name="item1" />
<input type="checkbox" val="2" class="control" name="item2" />
<input type="checkbox" val="3" class="control" name="item3" />
<input type="checkbox" val="4" class="control" name="item4" />
<br /><br />
<form>
Target:
<input type="checkbox" val="1" name="item1" disabled />
<input type="checkbox" val="2" name="item2" disabled />
<input type="checkbox" val="3" name="item3" disabled />
<input type="checkbox" val="4" name="item4" disabled />
</form>
<br /><br />
To use:
<ul>
<li>Make sure you jQuery + the checkmate plugin</li>
<li>Make sure that your "fake" inputs and your "real" inputs have the same <code>name</code> attribute</li>
<li>Give your all of your "fake" inputs the same class. In this demo, I used "control".</li>
<li>Attach the <code>checkmate()</code> function to a clickhandler on your "fake" inputs:<br />
<code>
$('input.control').click(function(){
$(this).checkmate();
});
</code>
</li>
</ul>
</body>
</html>