forked from hebertialmeida/Serialize-Table
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
195 lines (185 loc) · 6.61 KB
/
index.php
File metadata and controls
195 lines (185 loc) · 6.61 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>jQuery SerializeTable</title>
<meta content="jQuery SerializeTable is a jquery plugin that get data from table when click in row. And make into JSON all data, and can be read by PHP and return to input or to any element by AJAX." name="description">
<meta content="serialize table, javascript, javascript ajax, jquery" name="keywords">
<link rel="stylesheet" href="./css/style.css" />
</head>
<body>
<a href="https://github.com/hebertialmeida/Serialize-Table/"><img alt="Fork me on GitHub" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" style="position: fixed; top: 0pt; right: 0pt; border: 0pt none;"></a>
<div id="main">
<h1>jQuery SerializeTable Example</h1>
<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://hebertialmeida.com/plugins/serialize-table/" data-via="hebertialmeida">Tweet</a>
<ul id="nav">
<li><a href="http://hebertialmeida.com/plugins/serialize-table/#download">Download</a></li>
<li><a href="http://hebertialmeida.com/plugins/serialize-table/#documentation">Usage</a></li>
</ul>
<p>jQuery SerializeTable is a jquery plugin that get data from table when click in row. And make into JSON all data, and can be read by PHP and return to input or to any element by AJAX.</p>
<div id="demo">
<h2>Click in row to view demo</h2>
<table cellspacing="0" border="1">
<thead>
<tr>
<th>Name</th>
<th>University</th>
<th>Postcode</th>
<th>Region</th>
</tr>
</thead>
<tbody>
<tr>
<td rel="name">Heberti Almeida</td>
<td rel="university">Oxford Brookes</td>
<td rel="post_code">OX3 0BT</td>
<td rel="region">London</td>
</tr>
<tr>
<td rel="name">Luis Silva</td>
<td rel="university">Bath Spa</td>
<td rel="post_code">BA2 9BN</td>
<td rel="region">South West</td>
</tr>
<tr>
<td rel="name">Rafael Kowal</td>
<td rel="university">York College</td>
<td rel="post_code">YO23 2BB</td>
<td rel="region">North west</td>
</tr>
<tr>
<td rel="name">Isaque Siqueira</td>
<td rel="university">Oxford</td>
<td rel="post_code">OX1 2DH</td>
<td rel="region">London</td>
</tr>
<tr>
<td rel="name">Alex Arno</td>
<td rel="university">Worcester Tech</td>
<td rel="post_code">WR1 2JF</td>
<td rel="region">West Mids</td>
</tr>
<tr>
<td rel="name">Heber Aragão</td>
<td rel="university">York College</td>
<td rel="post_code">YO23 2BB</td>
<td rel="region">North west</td>
</tr>
</tbody>
</table>
</div>
<div id="return"></div>
<div id="documentation">
<h2>How to use it</h2>
<pre>
<code class="block"><script src="jquery.js"></script>
<script src="jquery.serializetable.js"></script>
<script>
$(document).ready(function() {
$("#your_table").serializeTable({
"file": "path/to/file.php",
"params": "parameter_name",
"data": "#element"
});
});
</script>
</code>
</pre>
<h2>Options</h2>
<ul class="opt">
<li><b>file:</b> Name of AJAX file. Defaults to <code class="small">empty</code>.</li>
<li><b>params:</b> Name of parameter to request. Defaults to <code class="small">params</code>.</li>
<li><b>data:</b> Element, ID or Class to return AJAX data. Defaults to <code class="small">#content</code>.</li>
<li><b>attr:</b> Attribute that contains the field name. Defaults to <code class="small">rel</code>.</li>
<li><b>loading_text:</b> Text displayed on loading. Defaults to <code class="small">empty</code>.</li>
<li><b>loading_class:</b> Class to personalize loading. Defaults to <code class="small">serializetable-ldg</code>.</li>
</ul>
<h2>Usage</h2>
<h3>Plugin</h3>
<pre>
<code class="block"><script>
$(document).ready(function() {
$("#my_table").serializeTable({
"file": "ajax.php",
"params": "juice",
"data": "#return"
});
});
</script>
</code>
</pre>
<h3>HTML</h3>
<pre>
<code class="block"><table>
<thead>
<tr>
<th>Name</th>
<th>Color</th>
</tr>
</thead>
<tbody>
<tr>
<td rel="name">Heberti</td>
<td rel="color">Blue</td>
</tr>
<tr>
<td rel="name">Luis</td>
<td rel="color">Green</td>
</tr>
</tbody>
</table>
<div id="return"></div>
</code>
</pre>
<h3>PHP REQUEST</h3>
<pre>
<code class="block"><?php
$json = $_REQUEST["juice"];
$obj = json_decode($json);
?>
<!-- Sample -->
<input type="text" value="<?php echo $obj[0]->name?>" />
<input type="text" value="<?php echo $obj[0]->color?>" />
</code>
</pre>
</div>
<div id="download">
<h2>Download</h2>
<ul class="opt">
<li><a href="https://github.com/hebertialmeida/Serialize-Table/raw/master/js/jquery.serializetable.js" title="Download normal version">jquery.serializetable.js</a></li>
<li><a href="https://github.com/hebertialmeida/Serialize-Table/raw/master/js/jquery.serializetable.min.js" title="Download minified version">jquery.serializetable.min.js</a></li>
<li><a href="https://github.com/hebertialmeida/Serialize-Table/archives/master" title="Download all files">All files in github</a></li>
</ul>
</div>
</div>
<div id="footer">
<a href="http://twitter.com/hebertialmeida">@hebertialmeida built this</a>
</div>
<!-- js -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="./js/jquery.serializetable.js"></script>
<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("table").serializeTable({
file: "ajax.php",
params: "registration",
data: "#return",
loading_text: "Loading..."
});
});
</script>
<!-- google analytics -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-12603960-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
<!-- end -->
</body>
</html>