source: schedule/function/SplitDelete.php@ 19594

Last change on this file since 19594 was 17218, checked in by tanio, 11 years ago
File size: 10.9 KB
Line 
1<script src="js/jquery-1.7.1.js"></script>
2<script language="javascript">
3 function clearNode(node){
4 var child = node.childNodes[0];
5 while(child != null)
6 {
7 node.removeChild(child);
8 child = node.childNodes[0];
9 }
10 }
11
12 function addRow(table){
13 var targetView = table;
14 // CREATE ELEMENT
15 var newtr = document.createElement("tr");
16
17 var newtd_c1 = document.createElement("td");
18 newtd_c1.setAttribute("width","147");
19 newtd_c1.setAttribute("align","center");
20 newtd_c1.appendChild(
21 input_data = document.createElement("input"),
22 input_data.setAttribute("type","time"),
23 input_data.setAttribute("size","10"),
24 input_data.setAttribute("autofocus","true"),
25 input_data.setAttribute("hidden","true")
26 );
27 var newtd_c2 = document.createElement("td");
28 newtd_c2.setAttribute("width","138");
29 newtd_c2.setAttribute("align","center");
30 newtd_c2.appendChild(
31
32
33
34 selection = document.createElement("select"),
35 <?php
36 $selectm = mysql_query("SELECT * FROM measurement");
37 while($rowmeasure = mysql_fetch_array($selectm)){
38
39 ?>
40 selection.appendChild(option = document.createElement("option"),option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))),
41 <?php } ?>
42 selection.setAttribute('id','source')
43 );
44
45
46
47
48
49 newtd_c2.setAttribute("width","115");
50 newtd_c2.setAttribute("align","center");
51 newtd_c2.appendChild(
52 input_data = document.createElement("input"),
53 input_data.setAttribute("type","button"),
54 input_data.setAttribute("id","plus"),
55 input_data.setAttribute("value","+"),
56 input_data.onclick = function(){ return addRow(newtr); }
57 );
58 var newtd_c3 = document.createElement("td");
59 newtd_c3.setAttribute("width","98");
60 newtd_c3.setAttribute("align","center");
61 newtd_c3.appendChild(
62 selection = document.createElement("select"),
63 <?php
64
65 $select = mysql_query("SELECT * FROM source");
66
67 while($rowsource = mysql_fetch_array($select)){
68
69 ?>
70 selection.appendChild(option = document.createElement("option"),option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),
71 <?php } ?>
72 selection.setAttribute('id','measurement')
73 );
74
75
76
77 var newtd_c4 = document.createElement("td");
78 newtd_c4.setAttribute("width","119");
79 newtd_c4.setAttribute("align","center");
80 newtd_c4.appendChild(
81 input_data = document.createElement("input"),
82 input_data.setAttribute("type","text"),
83 input_data.setAttribute("size","12"),
84 input_data.setAttribute("placeholder","Value")
85 );
86 var newtd_c5 = document.createElement("td");
87 newtd_c5.setAttribute("width","115");
88 newtd_c5.setAttribute("align","center");
89 newtd_c5.appendChild(
90 input_data = document.createElement("input"),
91 input_data.setAttribute("type","button"),
92 input_data.setAttribute("id","delete"),
93 input_data.setAttribute("value","Delete"),
94 input_data.onclick = function(){ return clearNode(newtr); }
95 );
96
97 newtr.appendChild(newtd_c2);
98 newtr.appendChild(newtd_c3);
99 newtr.appendChild(newtd_c4);
100 newtr.appendChild(newtd_c5);
101
102 $(targetView).after(newtr);
103 }
104 function deleteRow(tableID){
105 try{
106 var table = document.getElementById(tableID);
107 var rowCount = table.rows.length;
108
109 for(var i = 0; i < rowCount; i++){
110 var row = table.rows[i];
111 var chkbox = row.cells[0].childNodes[0];
112 if(null != chkbox && true == chkbox.checked){
113 if(rowCount <= 1){
114 alert("Cannot delete all the rows.");
115 break;
116 }
117 table.deleteRow(i);
118 rowCount--; i--;
119 }
120 }
121 }catch(e){
122 alert(e);
123 }
124 }
125
126
127function addRowClone(nextrow){
128 var targetView = document.getElementById("Data");
129 // CREATE ELEMENT
130 // COUNT LIST
131 var list = $(".datalisting").length;
132 var newlist = list+1;
133
134 var newdiv = document.createElement("div");
135 newdiv.setAttribute("id","list_"+newlist);
136 newdiv.setAttribute("class","datalisting");
137 newdiv.setAttribute("style","margin:30px 0;");
138 var newtable = document.createElement("table");
139 newtable.setAttribute("class","dataTable");
140 newtable.setAttribute("width","900");
141 newtable.setAttribute("border","1");
142 newtable.setAttribute("cellspacing","0");
143 newtable.setAttribute("cellpadding","0");
144 var newInnertable = document.createElement("table");
145 newInnertable.setAttribute("class","dataTable");
146 newInnertable.setAttribute("width","600");
147 newInnertable.setAttribute("border","1");
148 newInnertable.setAttribute("cellspacing","0");
149 newInnertable.setAttribute("cellpadding","0");
150
151 var newtr = document.createElement("tr");
152
153 var newtd_c1 = document.createElement("td");
154 newtd_c1.setAttribute("width","160");
155 newtd_c1.setAttribute("align","center");
156 newtd_c1.setAttribute("valign","top");
157 newtd_c1.appendChild(
158 input_data = document.createElement("input"),
159 input_data.setAttribute("type","time"),
160 input_data.setAttribute("size","10"),
161 input_data.setAttribute("autofocus","true")
162 );
163 newtd_c1.appendChild(
164 input_data = document.createElement("input"),
165 input_data.setAttribute("type","button"),
166 input_data.setAttribute("id","delete"),
167 input_data.setAttribute("value","+"),
168 input_data.onclick = function(){
169 addRowClone("list_"+newlist);
170 }
171 );
172 var newtd_c2 = document.createElement("td");
173 newtd_c2.setAttribute("width","118");
174 newtd_c2.setAttribute("align","center");
175 newtd_c2.appendChild(
176 selection = document.createElement("select"),
177 <?php
178 $selectm = mysql_query("SELECT * FROM measurement");
179 while($rowmeasure = mysql_fetch_array($selectm)){
180
181 ?>
182 selection.appendChild(option = document.createElement("option"),option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))),
183 <?php } ?>
184
185
186 selection.setAttribute('id','source')
187 );
188
189
190
191 newtd_c2.setAttribute("width","115");
192 newtd_c2.setAttribute("align","center");
193 newtd_c2.appendChild(
194 input_data = document.createElement("input"),
195 input_data.setAttribute("type","button"),
196 input_data.setAttribute("id","plus"),
197 input_data.setAttribute("value","+"),
198 input_data.onclick = function(){
199 return addRow(newtr);
200 });
201 var newtd_c3 = document.createElement("td");
202 newtd_c3.setAttribute("width","98");
203 newtd_c3.setAttribute("align","center");
204 newtd_c3.appendChild(
205 selection = document.createElement("select"),
206 <?php
207
208 $select = mysql_query("SELECT * FROM source");
209
210 while($rowsource = mysql_fetch_array($select)){
211
212 ?>
213 selection.appendChild(option = document.createElement("option"),option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),
214 <?php } ?>
215
216 selection.setAttribute('id','measurement')
217 );
218
219
220
221 var newtd_c4 = document.createElement("td");
222 newtd_c4.setAttribute("width","119");
223 newtd_c4.setAttribute("align","center");
224 newtd_c4.appendChild(
225 input_data = document.createElement("input"),
226 input_data.setAttribute("type","text"),
227 input_data.setAttribute("size","12"),
228 input_data.setAttribute("placeholder","Value")
229 );
230 var newtd_c5 = document.createElement("td");
231 newtd_c5.setAttribute("width","100");
232 newtd_c5.setAttribute("align","center");
233 newtd_c5.setAttribute("width","115");
234 newtd_c5.setAttribute("align","center");
235 newtd_c5.appendChild(
236 input_data = document.createElement("input"),
237 input_data.setAttribute("type","button"),
238 input_data.setAttribute("id","delete"),
239 input_data.setAttribute("value","Delete"),
240 input_data.onclick = function(){ return clearNode(newtr);
241 }
242 );
243 newtr.appendChild(newtd_c2);
244 newtr.appendChild(newtd_c3);
245 newtr.appendChild(newtd_c4);
246 newtr.appendChild(newtd_c5);
247
248 newInnertable.appendChild(newtr);
249 var newtd_c6 = document.createElement("td");
250 newtd_c6.appendChild(newInnertable);
251
252 var newtd_c7 = document.createElement("td");
253 newtd_c7.setAttribute("width","115");
254 newtd_c7.setAttribute("align","center");
255 newtd_c7.setAttribute("valign","top");
256 newtd_c7.appendChild(
257 input_data = document.createElement("input"),
258 input_data.setAttribute("type","button"),
259 input_data.setAttribute("height","30"),
260 input_data.setAttribute("id","delete"),
261 input_data.setAttribute("value","Delete Main"),
262 input_data.onclick = function(){ return clearNode(newdiv); }
263 );
264
265 var newOutertr = document.createElement("tr");
266
267 //newOutertr.appendChild(newtd_c1);
268 //newOutertr.appendChild(newtd_c6);
269 //newOutertr.appendChild(newtd_c7);
270
271 newtable.appendChild(newtd_c1);
272 newtable.appendChild(newtd_c6);
273 newtable.appendChild(newtd_c7);
274
275 newdiv.appendChild(newtable);
276 if(nextrow != null){
277 var doc = document.getElementById(nextrow);
278 $(doc).after(newdiv);
279 }else{
280 targetView.appendChild(newdiv);
281 }
282}
283
284window.onload = function(){
285 addRowClone();
286}
287
288</script>
289
290
291
292
293<style>
294#delete{
295 cursor: pointer;
296border-top: 1px solid #96d1f8;
297background: #65a9d7;
298background: -webkit-gradient(linear, left top, left bottom, from(#3e779d), to(#65a9d7));
299background: -webkit-linear-gradient(top, #3e779d, #65a9d7);
300background: -moz-linear-gradient(top, #3e779d, #65a9d7);
301background: -ms-linear-gradient(top, #3e779d, #65a9d7);
302background: -o-linear-gradient(top, #3e779d, #65a9d7);
303padding: 3px 6px;
304-webkit-border-radius: 6px;
305-moz-border-radius: 6px;
306border-radius: 6px;
307-webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;
308-moz-box-shadow: rgba(0,0,0,1) 0 1px 0;
309box-shadow: rgba(0,0,0,1) 0 1px 0;
310text-shadow: rgba(0,0,0,.4) 0 1px 0;
311color: white;
312font-size: 14px;
313font-family: 'Lucida Grande', Helvetica, Arial, Sans-Serif;
314text-decoration: none;
315vertical-align: middle;
316}
317#plus{
318 cursor: pointer;
319border-top: 1px solid #96d1f8;
320background: #65a9d7;
321background: -webkit-gradient(linear, left top, left bottom, from(#3e779d), to(#65a9d7));
322background: -webkit-linear-gradient(top, #3e779d, #65a9d7);
323background: -moz-linear-gradient(top, #3e779d, #65a9d7);
324background: -ms-linear-gradient(top, #3e779d, #65a9d7);
325background: -o-linear-gradient(top, #3e779d, #65a9d7);
326padding: 3px 6px;
327-webkit-border-radius: 6px;
328-moz-border-radius: 6px;
329border-radius: 6px;
330-webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;
331-moz-box-shadow: rgba(0,0,0,1) 0 1px 0;
332box-shadow: rgba(0,0,0,1) 0 1px 0;
333text-shadow: rgba(0,0,0,.4) 0 1px 0;
334color: white;
335font-size: 14px;
336font-family: 'Lucida Grande', Helvetica, Arial, Sans-Serif;
337text-decoration: none;
338vertical-align: middle;
339}
340</style>
341
342</head>
343<body>
344
345 <div id="Data">
346 </div>
347</body>
348</html>
Note: See TracBrowser for help on using the repository browser.