-
Notifications
You must be signed in to change notification settings - Fork 24
/
minimal.html
80 lines (66 loc) · 2.43 KB
/
minimal.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<style>
#container {
width: 800px;
margin: 0 auto;
}
#container > div {
margin-bottom: 1em;
}
</style>
<body>
<div id="container">
<p>
See <a href="https://github.com/miohtama/jquery-interdependencies">jQuery interdepedence Github project page</a> for more information.
</p>
<div>
<label>Diet</label>
<select id="diet">
<option value="normal">Normal</option>
<option value="special">Special considerations</option>
</select>
</div>
<div id="special-diet" style="margin-left: 2em">
<label for="text">
What kind of considerations
</label>
<input type="text" id="text" />
</div>
<div>
<label>
<span>Stay in hotel?</span>
<input type="checkbox" id="accomodation">
</label>
</div>
<div id="adults" style="margin-left: 2em">
<label>Number of adults</label>
<input type="number" />
</div>
<div id="children" style="margin-left: 2em">
<label>Number of children (younger than 12-years-old)</label>
<input type="number" />
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="deps.js"></script>
<script>
$(document).ready(function() {
// Start creating a new ruleset
var ruleset = $.deps.createRuleset();
// Show diet text input option only when special diet option is selected
var dietRule = ruleset.createRule("#diet", "==", "special");
dietRule.include("#special-diet");
// Make these fields visible when user checks hotel accomodation
var hotelRule = ruleset.createRule("#accomodation", "==", true);
hotelRule.include("#adults");
hotelRule.include("#children");
// Make the ruleset effective on the whole page
ruleset.install();
});
</script>
</body>
</html>