-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
144 lines (142 loc) · 6.92 KB
/
index.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html>
<head>
<title>jQuery form Helper by Davicotico</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
h1, h2, h3 { margin-top: 3rem; }
</style>
</head>
<body>
<div class="jumbotron jumbotron-fluid">
<div class="container">
<h1 class="display-3">jQuery formHelper by Davicotico</h1>
<p class="lead">Code less, do more. This plugin package is about that for form elements.</p>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<h2>Populate Form</h2>
<form id="myForm" action="http://127.0.0.1/codeigniter3/welcome/post" method="post">
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" name="username" id="username" placeholder="Username">
</div>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" name="email" id="email" placeholder="Enter email">
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name="check1" value="1">
Check me out
</label>
</div>
<div class="form-group">
<label for="select1">Simple Select</label>
<select name="select1" id="select1" class="form-control">
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>
</div>
<div class="form-group">
<label for="select2">Multiple Select</label>
<select name="select2[]" id="select2" size="10" multiple class="form-control">
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>
</div>
<div class="form-check">
<label>Multiple (Array) </label>
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name="check[]" value="1">
Option 1
</label>
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name="check[]" value="2">
Option 2
</label>
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name="check[]" value="3">
Option 3
</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>Check/Uncheck All</h2>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" id="masterCheck1"> Master check 1
</label>
</div>
<form id="myForm2">
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="check1[]" value="a"> A
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="check1[]" value="b"> B
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="check1[]" value="c"> C
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" id="masterCheck2"> Master check 2
</label>
</div>
</form>
</div>
</div>
</div>
<form id="myFormSimple" action="test.php" method="post">
<input type="text" name="field1" value="123">
<input type="text" name="field2" value="123">
<button type="submit" id="btnSubmit">Send</button>
</form>
<script src="js/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" crossorigin="anonymous"></script>
<script src="js/bootstrap.min.js"></script>
<script src="jquery.formHelper.js"></script>
<script>
$(document).ready(function () {
var values = {
username: "aaaa", //simple text
email: "david@email", //simple text
check1: "1", //simple checkbox
check: ["1", 3], //multiple checkbox
select1: "c", //simple select
select2: ['a', 'c'] //multiple select
};
$('#myForm').populateForm(values);
$('#myForm2').checkAll('check1', $('#masterCheck1'));
$('#myForm2').checkAll('check1', $('#masterCheck2'));
$('#myFormSimple').submit(function(e){
e.preventDefault();
function init($form){
console.log($form);
}
$(this).saveAjax({
before: init,
onSuccess: function(r){alert('Success: '+r);},
onError: function(r){ alert(JSON.stringify(r)); }
});
});
});
</script>
</body>
</html>