source: schedule/function/SplitDelete.php@ 16983

Last change on this file since 16983 was 16983, checked in by tanio, 11 years ago
File size: 8.1 KB
Line 
1
2<script src="js/jquery-1.7.1.js"></script>
3<script language="javascript">
4
5var timeval = 0;
6var name = "";
7var hid = "";
8var opt = "";
9window.cnt=0;
10 function clearNode(node){
11 var child = node.childNodes[0];
12 while(child != null)
13 {
14 node.removeChild(child);
15 child = node.childNodes[0];
16 }
17 }
18
19
20 function addRow(table){
21 $(this).prepend("tableID");
22 var targetView = table;
23 // CREATE ELEMENT
24 var newtr = document.createElement("tr");
25
26 var newtd_c1 = document.createElement("td");
27 newtd_c1.setAttribute("width","115");
28 newtd_c1.setAttribute("align","center");
29 newtd_c1.appendChild(
30 input_data = document.createElement("input"),
31 input_data.setAttribute("type","time"),
32 input_data.setAttribute("size","10"),
33 input_data.setAttribute("autofocus","true"),
34 input_data.setAttribute("hidden",true)
35 );
36 var newtd_c2 = document.createElement("td");
37 newtd_c2.setAttribute("width","40");
38 newtd_c2.setAttribute("align","center");
39 newtd_c2.appendChild(
40 selection = document.createElement("select"),
41 <?php
42 $selectm = mysql_query("SELECT * FROM measurement");
43 while($rowmeasure = mysql_fetch_array($selectm)){
44
45 ?>
46 selection.appendChild(option = document.createElement("option"),option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))),
47 <?php } ?>
48 selection.setAttribute('id','source')
49 );
50
51 //var newtd_c2 = document.createElement("td");
52 newtd_c2.setAttribute("width","115");
53 newtd_c2.setAttribute("align","center");
54 newtd_c2.appendChild(
55 input_data = document.createElement("input"),
56 input_data.setAttribute("type","button"),
57 input_data.setAttribute("value","[ + ]"),
58 input_data.onclick = function(){ return addRow(table); }
59 );
60
61 var newtd_c3 = document.createElement("td");
62 newtd_c3.setAttribute("width","88");
63 newtd_c3.setAttribute("align","center");
64 newtd_c3.appendChild(
65 selection = document.createElement("select"),
66 <?php
67
68 $select = mysql_query("SELECT * FROM source");
69
70 while($rowsource = mysql_fetch_array($select)){
71
72 ?>
73 selection.appendChild(option = document.createElement("option"),option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),
74 <?php } ?>
75 selection.setAttribute('id','measurement')
76 );
77 var newtd_c4 = document.createElement("td");
78 newtd_c4.setAttribute("width","180");
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","25"),
84 input_data.setAttribute("placeholder","Value")
85 );
86 var newtd_c5 = document.createElement("td");
87 newtd_c5.setAttribute("width","95");
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("value","[ Delete ]"),
93 input_data.onclick = function(){ return clearNode(newtr); }
94 );
95
96 newtr.appendChild(newtd_c1);
97 newtr.appendChild(newtd_c2);
98 newtr.appendChild(newtd_c3);
99 newtr.appendChild(newtd_c4);
100 newtr.appendChild(newtd_c5);
101 //newtr.appendChild(newtd_c6);
102
103 targetView.appendChild(newtr);
104
105 }
106
107 function deleteRow(tableID){
108 try{
109 var table=document.getElementById(tableID);
110 var rowCount=table.rows.length;
111
112 for(var i=0;i<rowCount;i++){
113 var row=table.rows[i];
114 var chkbox=row.cells[0].childNodes[0];
115 if(null!=chkbox&&true==chkbox.checked){
116 if(rowCount<=1){
117 alert("Cannot delete all the rows.");
118 break;
119 }
120 table.deleteRow(i);
121 rowCount--;i--;
122 }
123 }
124 }catch(e){
125 alert(e);
126 }
127 }
128
129
130function addRowClone(nextrow){
131 var targetView = document.getElementById("Data");
132 // CREATE ELEMENT
133 // COUNT LIST
134 var list = $(".datalisting").length;
135 var newlist = list+1;
136
137 var newdiv = document.createElement("div");
138 newdiv.setAttribute("id","list_"+newlist);
139 newdiv.setAttribute("class","datalisting");
140 newdiv.setAttribute("style","margin:5px 0;");
141 var newtable = document.createElement("table");
142 newtable.setAttribute("class","dataTable");
143 newtable.setAttribute("width","100%");
144 newtable.setAttribute("border","3");
145 newtable.setAttribute("cellspacing","0");
146 newtable.setAttribute("cellpadding","0");
147
148 var newtr = document.createElement("tr");
149
150 var newtd_c1 = document.createElement("td");
151 newtd_c1.setAttribute("width","115");
152 newtd_c1.setAttribute("align","center");
153 newtd_c1.appendChild(
154 input_data = document.createElement("input"),
155 input_data.setAttribute("type","time"),
156 input_data.setAttribute("size","10"),
157 input_data.setAttribute("autofocus","true")
158 );
159 newtd_c1.appendChild(
160 input_data = document.createElement("input"),
161 input_data.setAttribute("type","button"),
162 input_data.setAttribute("value","[ + ]"),
163 input_data.onclick = function(){
164 addRowClone("list_"+newlist);
165 }
166 );
167 var newtd_c2 = document.createElement("td");
168 newtd_c2.setAttribute("width","40");
169 newtd_c2.setAttribute("align","center");
170 newtd_c2.appendChild(
171 selection = document.createElement("select"),
172 <?php
173 $selectm = mysql_query("SELECT * FROM measurement");
174 while($rowmeasure = mysql_fetch_array($selectm)){
175
176 ?>
177 selection.appendChild(option = document.createElement("option"),option.setAttribute("value","<?php echo $rowmeasure['fMeasurementKey']; ?>"),option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))),
178 <?php } ?>
179
180
181 selection.setAttribute('id','source')
182 );
183
184// var newtd_c6 = document.createElement("td");
185 newtd_c2.setAttribute("width","115");
186 newtd_c2.setAttribute("align","center");
187 newtd_c2.appendChild(
188 input_data = document.createElement("input"),
189 input_data.setAttribute("type","button"),
190 input_data.setAttribute("value","[ + ]"),
191 input_data.onclick = function(){ return addRow(newtable); }
192 );
193 var newtd_c3 = document.createElement("td");
194 newtd_c3.setAttribute("width","98");
195 newtd_c3.setAttribute("align","center");
196 newtd_c3.appendChild(
197 selection = document.createElement("select"),
198 <?php
199
200 $select = mysql_query("SELECT * FROM source");
201
202 while($rowsource = mysql_fetch_array($select)){
203
204 ?>
205 selection.appendChild(option = document.createElement("option"),option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))),
206 <?php } ?>
207
208 selection.setAttribute('id','measurement')
209 );
210 var newtd_c4 = document.createElement("td");
211 newtd_c4.setAttribute("width","180");
212 newtd_c4.setAttribute("align","center");
213 newtd_c4.appendChild(
214 input_data = document.createElement("input"),
215 input_data.setAttribute("type","text"),
216 input_data.setAttribute("size","25"),
217 input_data.setAttribute("placeholder","Value")
218 );
219 var newtd_c5 = document.createElement("td");
220 newtd_c5.setAttribute("width","95");
221 newtd_c5.setAttribute("align","center");
222 newtd_c5.appendChild(
223 input_data = document.createElement("input"),
224 input_data.setAttribute("type","button"),
225 input_data.setAttribute("value","[ Delete Main ]"),
226 input_data.onclick = function(){ return clearNode(newdiv); }
227 );
228
229 newtr.appendChild(newtd_c1);
230 newtr.appendChild(newtd_c2);
231 newtr.appendChild(newtd_c3);
232 newtr.appendChild(newtd_c4);
233 newtr.appendChild(newtd_c5);
234 //newtr.appendChild(newtd_c6);
235
236 newtable.appendChild(newtr);
237 newdiv.appendChild(newtable);
238
239 if(nextrow != null){
240 var doc = document.getElementById(nextrow);
241 $(doc).after(newdiv);
242 }else{
243 targetView.appendChild(newdiv);
244 }
245}
246window.onload = function(){
247 addRowClone();
248}
249
250</script>
251
252
253</head>
254<body>
255
256 <div id="Data">
257 </div>
258</body>
259</html>
Note: See TracBrowser for help on using the repository browser.