source: schedule/function/SplitDelete.php@ 17087

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