source: schedule/function/SplitDelete.php@ 16507

Last change on this file since 16507 was 16507, checked in by tanio, 11 years ago
File size: 20.5 KB
Line 
1<script type="text/javascript">
2 $(document).ready(function(){
3 var timeValue;
4var meas;
5var meas2;
6 window.cnt=2;
7 var table = document.createElement("table");
8 table.setAttribute('id',"table2");
9 table.setAttribute('width','100%');
10 var tr = document.createElement('tr');
11 var td3=document.createElement('td');
12 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
13 td3.appendChild(
14 input = document.createElement("input"),
15 input.setAttribute("type","time"),
16 input.setAttribute("id","Time1"),
17 input.setAttribute("max","24"),
18 input.setAttribute("min","1"),
19 input.setAttribute("required",true)
20
21 );
22 td3.appendChild(
23 button=document.createElement('input'),
24 button.setAttribute('type','button'),
25 button.setAttribute('value','[+]'),
26 button.setAttribute('id','btnAddTime'),
27 button.onclick=function(){
28 if($('#Time1').val() != ""){ var splitting = $('#Time1').val().split(':'); var add = 01;
29
30 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
31
32 function pad(number, length) {
33
34 var str = '' + number;
35 while (str.length < length) {
36 str = '0' + str;
37 }
38
39 return str;
40
41 }
42
43 meas = "name"; meas2 = "time"; split1(); }else{ alert("please enter value for time to add measurement"); }
44
45
46 }
47 );
48 var td=document.createElement('td');
49 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
50 td.appendChild(
51 sourcecbo= document.createElement('select'),
52 sourcecbo.setAttribute('id','source1'),
53<?php
54 $source=mysql_query("SELECT*FROM source");
55 while($rowsource=mysql_fetch_array($source))
56 {
57?>
58 sourcecbo.appendChild(
59 option=document.createElement('option'),
60
61 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
62 option.setAttribute('selected',true),
63
64 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
65
66
67 ),
68<?php
69 }
70?>
71 sourcecbo.setAttribute('id','source1')
72
73 );
74 var td1=document.createElement('td');
75 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
76 td1.appendChild(
77 measurementcbo= document.createElement('select'),
78 measurementcbo.setAttribute('id','measurement1'),
79<?php
80 $measure=mysql_query("SELECT*FROM measurement");
81 while($rowmeasure=mysql_fetch_array($measure))
82 {
83?>
84 measurementcbo.appendChild(
85 option=document.createElement('option'),
86 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
87 option.setAttribute('selected',true),
88 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
89 ),
90<?php
91 }
92?>
93 measurementcbo.setAttribute('id','measurement1')
94 );
95 td1.appendChild(
96 button=document.createElement('input'),
97 button.setAttribute('type','button'),
98 button.setAttribute('value','[+]'),
99 button.setAttribute('id','btnAddTime'),
100 button.onclick=function(){
101 if($('#Time1').val() != ""){ timeValue = $('#Time1').val(); meas = "hidden"; meas2 = true; split1(); }else{ alert("please enter value for time to add measurement"); }
102
103
104 }
105 );
106 var td2=document.createElement('td');
107 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
108 td2.appendChild(
109 input = document.createElement('input'),
110 input.setAttribute('type','text'),
111 input.setAttribute('id','txtData1')
112
113
114 );
115 var td4=document.createElement('td');
116 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
117 td4.appendChild(
118 button = document.createElement('input'),
119 button.setAttribute("type",'button'),
120 button.setAttribute('id','btnSplit'),
121 button.setAttribute('value','Split'),
122 button.onclick= function()
123 {
124 if($('#Time1').val() != ""){ var splitting = $('#Time1').val().split(':'); var add = 30;
125
126 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
127
128 function pad(number, length) {
129
130 var str = '' + number;
131 while (str.length < length) {
132 str = '0' + str;
133 }
134
135 return str;
136
137 }
138
139 meas = "name"; meas2 = "time"; split1(); }else{ alert("please enter value for time to add measurement"); }
140
141
142
143 }
144 );
145 td4.appendChild(
146 button=document.createElement('input'),
147 button.setAttribute('type','button'),
148 button.setAttribute('value','Delete'),
149 button.setAttribute('id','btnDelete'),
150 button.onclick=function(){
151 $('#table2').remove();
152 }
153 );
154
155 tr.appendChild(td3);
156 tr.appendChild(td1);
157 tr.appendChild(td);
158
159 tr.appendChild(td2);
160 tr.appendChild(td4);
161 table.appendChild(tr);
162 $('#TableH1').append(table);
163
164
165 var table = document.createElement("table");
166 table.setAttribute('id',"table1");
167 table.setAttribute('width','100%');
168 var tr = document.createElement('tr');
169 tr.setAttribute('id','');
170 tr.setAttribute('class','');
171 var td3=document.createElement('td');
172 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
173 td3.appendChild(
174 input = document.createElement("input"),
175 input.setAttribute("type","time"),
176 input.setAttribute("id","Time2"),
177 input.setAttribute("max","24"),
178 input.setAttribute("min","1"),
179 input.setAttribute("required",true)
180 );
181 td3.appendChild(
182 button=document.createElement('input'),
183 button.setAttribute('type','button'),
184 button.setAttribute('value','[+]'),
185 button.setAttribute('id','btnAddTime'),
186 button.onclick=function(){
187 if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 01;
188
189 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
190
191 function pad(number, length) {
192
193 var str = '' + number;
194 while (str.length < length) {
195 str = '0' + str;
196 }
197
198 return str;
199
200 } meas = "name"; meas2 = "time"; split(); }else{ alert("please enter value for time to add measurement"); }
201
202
203 }
204 );
205 var td=document.createElement('td');
206 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
207 td.appendChild(
208 sourcecbo= document.createElement('select'),
209 sourcecbo.setAttribute('id','source2'),
210<?php
211 $source=mysql_query("SELECT*FROM source");
212 while($rowsource=mysql_fetch_array($source))
213 {
214?>
215 sourcecbo.appendChild(
216 option=document.createElement('option'),
217 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
218 option.setAttribute('selected',true),
219 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
220
221 ),
222<?php
223 }
224 ?>
225 sourcecbo.setAttribute('id','source2')
226
227 );
228 var td1=document.createElement('td');
229 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
230 td1.appendChild(
231 measurementcbo= document.createElement('select'),
232 measurementcbo.setAttribute('id','measurement2'),
233<?php
234 $measure=mysql_query("SELECT*FROM measurement");
235 while($rowmeasure=mysql_fetch_array($measure))
236 {
237?>
238 measurementcbo.appendChild(
239 option=document.createElement('option'),
240 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
241 option.setAttribute('selected',true),
242 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
243 ),
244<?php
245 }
246?>
247 measurementcbo.setAttribute('id','measurement2')
248 );
249 td1.appendChild(
250 button=document.createElement('input'),
251 button.setAttribute('type','button'),
252 button.setAttribute('value','[+]'),
253 button.setAttribute('id','btnAddTime'),
254 button.onclick=function(){
255 if($('#Time2').val() != ""){ timeValue = $('#Time2').val(); meas = "hidden"; meas2 = true; split(); }else{ alert("please enter value for time to add measurement"); }
256
257
258 }
259 );
260 var td2=document.createElement('td');
261 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
262 td2.appendChild(
263 input = document.createElement('input'),
264 input.setAttribute('type','text'),
265 input.setAttribute('id','txtData2')
266
267 );
268 var td4=document.createElement('td');
269 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
270 td4.appendChild(
271 button = document.createElement('input'),
272 button.setAttribute("type",'button'),
273 button.setAttribute('id','btnSplit'),
274 button.setAttribute('value','Split'),
275 button.onclick= function()
276 {
277 if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 30;
278
279 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
280
281 function pad(number, length) {
282
283 var str = '' + number;
284 while (str.length < length) {
285 str = '0' + str;
286 }
287
288 return str;
289
290 }
291
292 meas = "name"; meas2 = "time"; split(); }else{ alert("please enter value for time to add measurement"); }
293
294 }
295 );
296 td4.appendChild(
297 button=document.createElement('input'),
298 button.setAttribute('type','button'),
299 button.setAttribute('value','Delete'),
300 button.setAttribute('id','btnDelete'),
301 button.onclick=function(){
302 $('#table1').remove();
303
304 }
305 );
306
307 tr.appendChild(td3);
308 tr.appendChild(td1);
309 tr.appendChild(td);
310
311 tr.appendChild(td2);
312 tr.appendChild(td4);
313 table.appendChild(tr);
314 $('#TableH').append(table);
315 var meas;
316 var timeValue;
317
318 function split()
319 {
320 if(cnt <= 10){
321 cnt++;
322 var table = document.createElement("table");
323 table.setAttribute('id',"table"+cnt);
324 table.setAttribute('width','100%');
325 var tr = document.createElement('tr');
326 tr.setAttribute('id','');
327 tr.setAttribute('class','');
328
329 var td3=document.createElement('td');
330 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
331 td3.setAttribute('class','first');
332
333 td3.appendChild(
334 input = document.createElement("input"),
335 input.setAttribute("type","time"),
336 input.setAttribute("id","Time"+cnt),
337 input.setAttribute("max","24"),
338 input.setAttribute("min","1"),
339 input.setAttribute("required",true),
340 input.setAttribute(meas,meas2),
341 input.setAttribute("value",timeValue)
342
343 );
344 td3.appendChild(
345 button=document.createElement('input'),
346 button.setAttribute('type','button'),
347 button.setAttribute('value','[+]'),
348 button.setAttribute('id','btnAddTime'),
349 button.setAttribute(meas,meas2),
350 button.onclick=function(){
351 if($('#Time'+cnt).val() != ""){var splitting = $('#Time'+cnt).val().split(':'); var add = 01;
352
353 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
354
355 function pad(number, length) {
356
357 var str = '' + number;
358 while (str.length < length) {
359 str = '0' + str;
360 }
361
362 return str;
363
364 } meas = "name"; meas2 = "time"; split1(); }else{ alert("please enter value for time to add measurement"); }
365
366
367 }
368 );
369
370 var td=document.createElement('td');
371 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
372 td.appendChild(
373 sourcecbo= document.createElement('select'),
374 sourcecbo.setAttribute('id','source'+cnt),
375<?php
376 $source=mysql_query("SELECT*FROM source");
377 while($rowsource=mysql_fetch_array($source))
378 {
379?>
380 sourcecbo.appendChild(
381 option=document.createElement('option'),
382 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
383 option.setAttribute('selected',true),
384 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
385
386 ),
387<?php
388 }
389 ?>
390 sourcecbo.setAttribute('id','source'+cnt)
391
392 );
393 var td1=document.createElement('td');
394 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
395 td1.appendChild(
396 measurementcbo= document.createElement('select'),
397 measurementcbo.setAttribute('id','measurement'+cnt),
398<?php
399 $measure=mysql_query("SELECT*FROM measurement");
400 while($rowmeasure=mysql_fetch_array($measure))
401 {
402?>
403 measurementcbo.appendChild(
404 option=document.createElement('option'),
405 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
406 option.setAttribute('selected',true),
407 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
408 ),
409<?php
410 }
411?>
412 measurementcbo.setAttribute('id','measurement'+cnt)
413 );
414 td1.appendChild(
415 button=document.createElement('input'),
416 button.setAttribute('type','button'),
417 button.setAttribute('value','[+]'),
418 button.setAttribute('id','btnAddTime'),
419 button.onclick=function(){
420
421 if($('#Time'+cnt).val() != ""){ timeValue = $('#Time'+cnt).val(); meas = "hidden"; meas2 = true; split1(); }else{ alert("please enter value for time to add measurement"); }
422
423
424 }
425 );
426
427 var td2=document.createElement('td');
428 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
429 td2.appendChild(
430 input = document.createElement('input'),
431 input.setAttribute('type','text'),
432 input.setAttribute('id','txtData'+cnt)
433
434 );
435 var td4=document.createElement('td');
436 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
437 td4.appendChild(
438 button = document.createElement('input'),
439 button.setAttribute("type",'button'),
440 button.setAttribute('id','btnSplit'),
441 button.setAttribute('value','Split'),
442 button.onclick=function(){
443 if($('#Time'+cnt).val() != ""){ var splitting = $('#Time'+cnt).val().split(':'); var add = 30;
444
445 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
446
447 function pad(number, length) {
448
449 var str = '' + number;
450 while (str.length < length) {
451 str = '0' + str;
452 }
453
454 return str;
455
456 }
457
458 meas = "name"; meas2 = "time"; split(); }else{ alert("please enter value for time to add measurement"); }
459 }
460 );
461 td4.appendChild(
462 button=document.createElement('input'),
463 button.setAttribute('type','button'),
464 button.setAttribute('value','Delete'),
465 button.setAttribute('id','btnDelete'),
466 button.onclick=function(){
467 $('#table'+cnt).remove();
468 cnt--;
469 }
470 );
471
472 tr.appendChild(td3);
473 tr.appendChild(td1);
474 tr.appendChild(td);
475
476 tr.appendChild(td2);
477 tr.appendChild(td4);
478 table.appendChild(tr);
479 $('#TableH').append(table);
480 }else{
481
482 alert(" only 10 sources are allowed! ");
483
484 }
485
486 }
487 function split1()
488 {
489 if(cnt <= 10){
490 cnt++;
491 var table = document.createElement("table");
492 table.setAttribute('id',"table"+cnt);
493 table.setAttribute('width','100%');
494 var tr = document.createElement('tr');
495 tr.setAttribute('id','');
496 tr.setAttribute('class','');
497
498 var td3=document.createElement('td');
499 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
500 td3.setAttribute('class','first');
501 td3.appendChild(
502 input = document.createElement("input"),
503 input.setAttribute("type","time"),
504 input.setAttribute("id","Time"+cnt),
505 input.setAttribute("max","24"),
506 input.setAttribute("min","1"),
507 input.setAttribute("required",true),
508 input.setAttribute(meas,meas2),
509 input.setAttribute("value",timeValue)
510 );
511 td3.appendChild(
512 button=document.createElement('input'),
513 button.setAttribute('type','button'),
514 button.setAttribute('value','[+]'),
515 button.setAttribute('id','btnAddTime'),
516 button.setAttribute(meas,meas2),
517 button.onclick=function(){
518 if($('#Time'+cnt).val() != ""){ var splitting = $('#Time'+cnt).val().split(':'); var add = 01;
519
520 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
521
522 function pad(number, length) {
523
524 var str = '' + number;
525 while (str.length < length) {
526 str = '0' + str;
527 }
528
529 return str;
530
531 } meas = "name"; meas2 = "time"; split1(); }else{ alert("please enter value for time to add measurement"); }
532
533
534 }
535 );
536
537 var td=document.createElement('td');
538 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
539 td.appendChild(
540 sourcecbo= document.createElement('select'),
541 sourcecbo.setAttribute('id','source'+cnt),
542<?php
543 $source=mysql_query("SELECT*FROM source");
544 while($rowsource=mysql_fetch_array($source))
545 {
546?>
547 sourcecbo.appendChild(
548 option=document.createElement('option'),
549 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
550 option.setAttribute('selected',true),
551 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
552
553 ),
554<?php
555 }
556 ?>
557 sourcecbo.setAttribute('id','source'+cnt)
558
559 );
560 var td1=document.createElement('td');
561 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
562
563 td1.appendChild(
564 measurementcbo= document.createElement('select'),
565 measurementcbo.setAttribute('id','measurement'+cnt),
566<?php
567 $measure=mysql_query("SELECT*FROM measurement");
568 while($rowmeasure=mysql_fetch_array($measure))
569 {
570?>
571 measurementcbo.appendChild(
572 option=document.createElement('option'),
573 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
574 option.setAttribute('selected',true),
575 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
576 ),
577<?php
578 }
579?>
580 measurementcbo.setAttribute('id','measurement'+cnt)
581 );
582 td1.appendChild(
583 button=document.createElement('input'),
584 button.setAttribute('type','button'),
585 button.setAttribute('value','[+]'),
586 button.setAttribute('id','btnAddTime'),
587 button.onclick=function(){
588
589 if($('#Time'+cnt).val() != ""){ timeValue = $('#Time'+cnt).val(); meas = "hidden"; meas2 = true; split1(); }else{ alert("please enter value for time to add measurement"); }
590
591
592 }
593 );
594
595 var td2=document.createElement('td');
596 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
597 td2.appendChild(
598 input = document.createElement('input'),
599 input.setAttribute('type','text'),
600 input.setAttribute('id','txtData'+cnt)
601
602 );
603 var td4=document.createElement('td');
604 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
605 td4.appendChild(
606 button = document.createElement('input'),
607 button.setAttribute("type",'button'),
608 button.setAttribute('id','btnSplit'),
609 button.setAttribute('value','Split'),
610 button.onclick=function(){
611 if($('#Time'+cnt).val() != ""){ var splitting = $('#Time'+cnt).val().split(':'); var add = 30;
612
613 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
614
615 function pad(number, length) {
616
617 var str = '' + number;
618 while (str.length < length) {
619 str = '0' + str;
620 }
621
622 return str;
623
624 }
625
626 meas = "name"; meas2 = "time"; split(); }else{ alert("please enter value for time to add measurement"); }
627 }
628 );
629 td4.appendChild(
630 button=document.createElement('input'),
631 button.setAttribute('type','button'),
632 button.setAttribute('value','Delete'),
633 button.setAttribute('id','btnDelete'),
634 button.onclick=function(){
635 $('#table'+cnt).remove();
636 cnt--;
637 });
638
639 tr.appendChild(td3);
640 tr.appendChild(td1);
641 tr.appendChild(td);
642
643 tr.appendChild(td2);
644 tr.appendChild(td4);
645 table.appendChild(tr);
646 $('#TableH1').append(table);
647 }else{
648
649 alert(" only 10 sources are allowed! ");
650 }
651 }
652
653 });
654 </script>
Note: See TracBrowser for help on using the repository browser.