-
Notifications
You must be signed in to change notification settings - Fork 18
/
sample.html
77 lines (72 loc) · 2.55 KB
/
sample.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
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script src="src/jquery.jsForm.js"></script>
<script>
$(function(){
// some json data
var jsonData = {
name: "TestName", // standard inputs
description: "long Description\nMultiline", // textarea
links: [{href:'http://www.gargan.org',description:'Gargan.org'},{href:'http://www.github.com',description:'GitHub'}], // lists
active: true, // checkbox
type: "COOL", // radio (enums)
state: "VISIBLE", // selects (enums)
age: 45, // number
quips: ["Don't left school interfere with your education!", "Can you repeat the question? I was thinking about cookies.", "In my house I'm the boss, my wife is just the decision maker."],
config: {
colors: ["green"]
}
};
// initialize the form, prefix is optional and defaults to data
$("#details").jsForm({
data:jsonData
});
$("#show").click(function() {
// show the json data
alert(JSON.stringify($("#details").jsForm("get"), null, " "));
});
});
</script>
</head>
<body>
<h1>Simple Form Test</h1>
<div id="details">
Name: <input name="data.name"/><br/>
<input type="checkbox" name="data.active"/> active<br/>
Age: <input name="data.age" class="number"/><br/>
<textarea name="data.description"></textarea><br/>
<select name="data.state">
<option value="VISIBLE">visible</option>
<option value="IMPORTANT">important</option>
<option value="HIDDEN">hidden</option>
</select>
<br/>
<input type="radio" name="data.type" value="COOL"/> Cool<br/>
<input type="radio" name="data.type" value="HOT"/> Hot<br/>
<input type="radio" name="data.type" value="WARM"/> Warm<br/>
<fieldset>
<legend>Links</legend>
<ul class="collection" data-field="data.links">
<li><span class="field">links.description</span> Link: <input name="links.href"/> <button class="delete">x</button></li>
</ul>
</fieldset>
<button class="add" data-field="data.links">add a link</button><br/>
Additional field: <input name="data.addedField"/>
<fieldset>
<legend>Quips</legend>
<ul class="collection" data-field="data.quips">
<li><input name="quips."/></li>
</ul>
<button class="add" data-field="data.quips">add a quip</button><br/>
</fieldset>
<fieldset>
<legend>Favorite Colors</legend>
<input type="checkbox" name="data.config.colors" class="array" value="red"/> Red
<input type="checkbox" name="data.config.colors" class="array" value="green"/> Green
<input type="checkbox" name="data.config.colors" class="array" value="blue"/> Blue
</fieldset>
</div>
<button id="show">Show Object</button>
</body>
</html>