forked from citnvillareal/serializeObject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
102 lines (80 loc) · 3.54 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
<html>
<head>
<title>Serialize Array to Json Object</title>
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/jquery.serializeObject.min.js"></script>
</head>
<body>
<form enctype='multipart/form-data'>
<select name="select_multiple[]" multiple>
<option>opt 1</option>
<option>opt 2</option>
<option>opt 3</option>
</select><br/>
<input type="checkbox" name="check[]" value="1" />true<br/>
<input type="checkbox" name="check[]" value="0" />false<br/>
<input type="radio" name="radio" value="1" />true<br/>
<input type="radio" name="radio" value="0" />false<br/>
<textarea name="textarea">test</textarea>
<br/>txt00<br/>
<input type="text" name="txt00" value="1009"><br/><br/>
<br/>txt01[][profiletitle]<br/>
<input type="text" name="txt01[][profiletitle]" value="Profile Title"><br/>
<br/>txt01[][aboutme]<br/>
<input type="text" name="txt01[][aboutme]" value="About Me"><br/>
<br/>txt01[][worktype]<br/>
<input type="text" name="txt01[][worktype]" value="Internship/Trainee"><br/><br/>
<br/>txt02[][dup_interest_id]<br/>
<input type="text" name="txt02[][dup_interest_id]" value="4000000018"><br/>
<br/>txt02[][dup_interest_name]<br/>
<input type="text" name="txt02[][dup_interest_name]" value="Badminton"><br/>
<br/>txt02[][dup_interest_rating]<br/>
<input type="text" name="txt02[][dup_interest_rating]" value="1"><br/>
<br/>txt02[][flag]<br/>
<input type="text" name="txt02[][flag]" value="E"><br/><br/>
<br/>txt02[][dup_interest_id]<br/>
<input type="text" name="txt02[][dup_interest_id]" value="4000000019"><br/>
<br/>txt02[][dup_interest_name]<br/>
<input type="text" name="txt02[][dup_interest_name]" value="Boxing"><br/>
<br/>txt02[][dup_interest_rating]<br/>
<input type="text" name="txt02[][dup_interest_rating]" value="1"><br/>
<br/>txt02[][flag]<br/>
<input type="text" name="txt02[][flag]" value="E"><br/><br/>
<br/>txt03[][profiletitle]<br/>
<input type="text" name="txt03[][profiletitle]" value="Profile Title"><br/>
<br/>txt03[][aboutme]<br/>
<input type="text" name="txt03[][aboutme]" value="About Me"><br/>
<br/>txt03[][worktype]<br/>
<input type="text" name="txt03[][worktype]" value="Internship/Trainee"><br/><br/>
<br/>txt04[dup_interest_id][]<br/>
<input type="text" name="txt04[dup_interest_id][]" value="4000000018"><br/>
<br/>txt04[dup_interest_name][]<br/>
<input type="text" name="txt04[dup_interest_name][]" value="Badminton"><br/>
<br/>txt04[dup_interest_rating][]<br/>
<input type="text" name="txt04[dup_interest_rating][]" value="1"><br/>
<br/>txt04[flag][]<br/>
<input type="text" name="txt04[flag][]" value="E"><br/>
<br/>txt04[dup_interest_id][]<br/>
<input type="text" name="txt04[dup_interest_id][]" value="4000000019"><br/>
<br/>txt04[dup_interest_name][]<br/>
<input type="text" name="txt04[dup_interest_name][]" value="Boxing"><br/>
<br/>txt04[dup_interest_rating][]<br/>
<input type="text" name="txt04[dup_interest_rating][]" value="1"><br/>
<br/>txt04[flag][]<br/>
<input type="text" name="txt04[flag][]" value="E"><br/>
<input type="file" name="file" />
<br/><br/><input type="submit">
</form>
<div id="result" style="border: 1px solid #ccc; margin: 20px;padding:20px;"></div>
<script type="text/javascript">
$(document).ready(function(){
$("form").submit(function(event){
event.preventDefault();
var jsonObject = $(this).serializeObject();
console.log(jsonObject);
$("#result").html(JSON.stringify(jsonObject));
});
});
</script>
</body>
</html>