source: schedule/function/SplitDelete.php@ 16899

Last change on this file since 16899 was 16899, checked in by tanio, 11 years ago
File size: 28.0 KB
Line 
1<script type="text/javascript">
2 $(document).ready(function(){
3 var name='';
4var value='';
5 var timeValue;
6var meas;
7var meas2;
8var getTableId;
9var is=0;
10 window.cnt=0;
11 var x = 0;
12 <?php
13 include '../include/factdb.php';
14 if(isset($_GET['days']))
15 {
16 $day = $_GET['days'];
17 }
18 else
19 {
20 $day =date("Y-m-d");
21 }
22 $days = Date('Y-m-d',strtotime($day));
23 $fetch = mysql_query("SELECT * FROM schedule") or die(mysql_error());
24 while($rows = mysql_fetch_array($fetch))
25 {
26 $timestamp=strtotime($rows['fStart']);
27 $timestamp2 = date('Y-m-d',$timestamp);
28 $date_time = date('H:i',$timestamp);
29
30 if($days == $timestamp2)
31 {
32 ?>
33 cnt++;
34
35$('#save').hide();
36 $('#update').show();
37
38 var div= document.createElement("div");
39 div.setAttribute('id','TableHolder');
40 var table = document.createElement("table");
41 table.setAttribute('id',"table"+cnt);
42 table.setAttribute('width','100%');
43 var tr = document.createElement('tr');
44 var td3=document.createElement('td');
45 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
46 td3.appendChild(
47 input = document.createElement("input"),
48 input.setAttribute("type","time"),
49 input.setAttribute("id","Time"),
50 input.setAttribute("max","24"),
51 input.setAttribute("min","1"),
52 input.setAttribute("required",true),
53 input.setAttribute("value",'<?php echo $date_time; ?>')
54
55 );
56 td3.appendChild(
57 button=document.createElement('input'),
58 button.setAttribute('type','button'),
59 button.setAttribute('value','[+]'),
60 button.setAttribute('id','btnAddTime'),
61 button.setAttribute('name','#table'+cnt),
62 button.onclick=function(){
63
64
65
66 if($('#Time').val() != ""){ var splitting = $('#Time').val().split(':'); var add = 01;
67
68 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
69
70 function pad(number, length) {
71
72 var str = '' + number;
73 while (str.length < length) {
74 str = '0' + str;
75 }
76
77 return str;
78
79 }
80 var s = 0; var get;
81 var nn;
82 nn = $(this).attr('name');
83 $("table").each(function() {
84 if($(this).attr("name")==nn){
85
86 get = "#"+$(this).attr("id");
87 //get = $(this).attr("name");
88 s =1;
89 }else{
90 if(s==0){
91 get = '#table'+cnt;
92 }
93 }
94 });
95
96
97
98 getTableId =get;
99
100
101 name="name"; value=""; meas = "name"; meas2 = "time"; //getTableId = $(this).attr('name');
102 split1(); }else{ alert("please enter value for time to add measurement"); }
103
104
105 }
106 );
107 var td=document.createElement('td');
108 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
109 td.appendChild(
110 sourcecbo= document.createElement('select'),
111 sourcecbo.setAttribute('id','source'),
112<?php
113 $source=mysql_query("SELECT*FROM source");
114 while($rowsource=mysql_fetch_array($source))
115 {
116?>
117 sourcecbo.appendChild(
118 option=document.createElement('option'),
119
120 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
121 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo"option.setAttribute('selected',true),"; } ?>
122
123
124 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
125
126
127 ),
128<?php
129 }
130?>
131 sourcecbo.setAttribute('id','source')
132
133 );
134 var td1=document.createElement('td');
135 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
136 td1.appendChild(
137 measurementcbo= document.createElement('select'),
138 measurementcbo.setAttribute('id','measurement'),
139<?php
140 $measure=mysql_query("SELECT*FROM measurement");
141 while($rowmeasure=mysql_fetch_array($measure))
142 {
143?>
144 measurementcbo.appendChild(
145 option=document.createElement('option'),
146 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
147
148 <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?>
149
150 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
151 ),
152<?php
153 }
154?>
155 measurementcbo.setAttribute('id','measurement')
156 );
157 td1.appendChild(
158 button=document.createElement('input'),
159 button.setAttribute('type','button'),
160 button.setAttribute('value','[+]'),
161 button.setAttribute('id','btnAddTime'),
162 button.setAttribute('name','#table'+cnt),
163 button.onclick=function(){
164 if($('#Time').val() != ""){ timeValue = $('#Time').val(); name="name"; value=$(this).attr('name'); meas = "hidden"; meas2 = true; is=1; getTableId = $(this).attr('name'); split1(); }else{ alert("please enter value for time to add measurement"); }
165
166
167 }
168 );
169 var td2=document.createElement('td');
170 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
171 td2.appendChild(
172 input = document.createElement('input'),
173 input.setAttribute('type','text'),
174 input.setAttribute('id','txtData'),
175 input.setAttribute('value','<?php echo $rows['fData']; ?>')
176
177
178 );
179 var td4=document.createElement('td');
180 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
181 td4.appendChild(
182 button=document.createElement('input'),
183 button.setAttribute('type','button'),
184 button.setAttribute('value','Delete'),
185 button.setAttribute('id','btnDelete'),
186 button.onclick=function(){
187 $('#table'+cnt).remove();
188 }
189 );
190
191 tr.appendChild(td3);
192 tr.appendChild(td1);
193 tr.appendChild(td);
194
195 tr.appendChild(td2);
196 tr.appendChild(td4);
197 table.appendChild(tr);
198 div.appendChild(table);
199 $('#TableH1').append(div);
200
201 <?php
202 }
203 }
204 ?>
205
206 if(cnt==0)
207 {
208 $('#save').show();
209 $('#update').hide();
210 var div= document.createElement("div");
211 div.setAttribute('id','TableHolder');
212 var table = document.createElement("table");
213 table.setAttribute('id',"table2");
214 table.setAttribute('width','100%');
215 table.setAttribute('name','#table2');
216 var tr = document.createElement('tr');
217 tr.setAttribute('id','');
218 tr.setAttribute('class','');
219 var td3=document.createElement('td');
220 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
221 td3.appendChild(
222 input = document.createElement("input"),
223 input.setAttribute("type","time"),
224 input.setAttribute("id","Time"),
225 input.setAttribute("max","24"),
226 input.setAttribute("min","1"),
227 input.setAttribute("required",true),
228 input.onkeyup = function(){
229
230
231
232
233 if($('div#TableHolder #table2 #Time').val() <= 0 || $('div#TableHolder #table1 #Time').val() <=0){
234
235
236 }else{
237 if($('div#TableHolder #table1 #Time').val() <= $('div#TableHolder #table2 #Time').val()){
238 alert('2nd row must be greater than 1st');
239 }
240 }
241
242
243
244
245
246
247 }
248
249
250 );
251 td3.appendChild(
252 button=document.createElement('input'),
253 button.setAttribute('type','button'),
254 button.setAttribute('value','[+]'),
255 button.setAttribute('id','btnAddTime'),
256 button.setAttribute('name','#table2'),
257 button.onclick=function(){
258 var aa;
259 $('div#TableHolder #table2 #Time').each(function(){
260 aa = $(this).val();
261 });
262
263 if(aa != ""){ var splitting =aa.split(':'); var add = 01;
264
265 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
266
267 function pad(number, length) {
268
269 var str = '' + number;
270 while (str.length < length) {
271 str = '0' + str;
272 }
273
274 return str;
275
276 };
277
278 var s = 0; var get;
279
280 $("table").each(function() { if($(this).attr("name")=='#table2'){ get = "#"+$(this).attr("id"); s =1; }else{ if(s==0){ get = '#table'+cnt; }
281 }
282 });
283getTableId =get;
284name="name"; value = '#table2';
285 meas = "class"; meas2 = "time"; //getTableId = $(this).attr('name');
286 split2(); }else{ alert("please enter value for time to add measurement"); }
287
288
289 }
290 );
291 var td=document.createElement('td');
292 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
293 td.appendChild(
294 sourcecbo= document.createElement('select'),
295 sourcecbo.setAttribute('id','source'),
296<?php
297 $source=mysql_query("SELECT*FROM source");
298 while($rowsource=mysql_fetch_array($source))
299 {
300?>
301 sourcecbo.appendChild(
302 option=document.createElement('option'),
303 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
304 option.setAttribute('selected',true),
305 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
306
307 ),
308<?php
309 }
310 ?>
311 sourcecbo.setAttribute('id','source')
312
313 );
314 var td1=document.createElement('td');
315 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
316 td1.appendChild(
317 measurementcbo= document.createElement('select'),
318 measurementcbo.setAttribute('id','measurement'),
319<?php
320 $measure=mysql_query("SELECT*FROM measurement");
321 while($rowmeasure=mysql_fetch_array($measure))
322 {
323?>
324 measurementcbo.appendChild(
325 option=document.createElement('option'),
326 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
327 option.setAttribute('selected',true),
328 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
329 ),
330<?php
331 }
332?>
333 measurementcbo.setAttribute('id','measurement')
334 );
335 td1.appendChild(
336 button=document.createElement('input'),
337 button.setAttribute('type','button'),
338 button.setAttribute('value','[+]'),
339 button.setAttribute('id','btnAddTime'),
340 button.setAttribute('name','#table2'),
341 button.onclick=function(){
342 var aa;
343 $('div#TableHolder #table2 #Time').each(function(){
344 aa = $(this).val();
345 });
346 if(aa != ""){ timeValue =aa; name="name"; value=$(this).attr('name'); meas = "hidden"; meas2 = true; getTableId = $(this).attr('name'); split2(); }else{ alert("please enter value for time to add measurement"); }
347
348
349 }
350 );
351 var td2=document.createElement('td');
352 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
353 td2.appendChild(
354 input = document.createElement('input'),
355 input.setAttribute('type','text'),
356 input.setAttribute('id','txtData')
357
358 );
359 var td4=document.createElement('td');
360 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
361
362 td4.appendChild(
363 button=document.createElement('input'),
364 button.setAttribute('type','button'),
365 button.setAttribute('value','Delete'),
366 button.setAttribute('id','btnDelete'),
367 button.onclick=function(){
368 $('#table2').remove();
369
370 }
371 );
372
373 tr.appendChild(td3);
374 tr.appendChild(td1);
375 tr.appendChild(td);
376
377 tr.appendChild(td2);
378 tr.appendChild(td4);
379 table.appendChild(tr);
380 div.appendChild(table);
381 $('#TableH1').append(div);
382
383 var div= document.createElement("div");
384 div.setAttribute('id','TableHolder');
385 var table = document.createElement("table");
386 table.setAttribute('id',"table1");
387 table.setAttribute('width','100%');
388 var tr = document.createElement('tr');
389 tr.setAttribute('id','');
390 tr.setAttribute('class','');
391 var td3=document.createElement('td');
392 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
393 td3.appendChild(
394 input = document.createElement("input"),
395 input.setAttribute("type","time"),
396 input.setAttribute("id","Time"),
397 input.setAttribute("max","24"),
398 input.setAttribute("min","1"),
399 input.setAttribute("required",true),
400 input.onkeyup = function(){
401
402
403
404
405
406 if($('div#TableHolder #table2 #Time').val() <= 0 || $('div#TableHolder #table1 #Time').val() <=0){
407
408
409 }else{
410 if($('div#TableHolder #table1 #Time').val() <= $('div#TableHolder #table2 #Time').val()){
411 alert(' row must be greater than previous');
412 return false;
413 }
414 }
415
416
417
418
419
420
421 }
422 );
423 td3.appendChild(
424 button=document.createElement('input'),
425 button.setAttribute('type','button'),
426 button.setAttribute('value','[+]'),
427 button.setAttribute('id','btnAddTime'),
428 button.setAttribute('name','#table1'),
429 button.onclick=function(){
430 var aa;
431 $('div#TableHolder #table1 #Time').each(function(){
432 aa = $(this).val();
433 });
434 if(aa !='') { var splitting =aa.split(':'); var add = 01;
435
436 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
437
438 function pad(number, length) {
439
440 var str = '' + number;
441 while (str.length < length) {
442 str = '0' + str;
443 }
444
445 return str;
446
447 };
448
449
450 var s = 0; var get;
451
452$("table").each(function() {
453 if($(this).attr("name")=='#table1'){
454 get = "#"+$(this).attr("id");
455
456 s =1;
457 }else{
458 if(s==0){
459 get = '#table1';
460 }
461 }
462 });
463getTableId =get;
464name="name"; value = '#table1';
465
466 meas = "class"; meas2 = "time"; //getTableId = $(this).attr('name');
467split2(); }else{ alert("please enter value for time to add measurement"); }
468
469
470 }
471 );
472 var td=document.createElement('td');
473 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
474 td.appendChild(
475 sourcecbo= document.createElement('select'),
476 sourcecbo.setAttribute('id','source'),
477<?php
478 $source=mysql_query("SELECT*FROM source");
479 while($rowsource=mysql_fetch_array($source))
480 {
481?>
482 sourcecbo.appendChild(
483 option=document.createElement('option'),
484 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
485 option.setAttribute('selected',true),
486 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
487
488 ),
489<?php
490 }
491 ?>
492 sourcecbo.setAttribute('id','source')
493
494 );
495 var td1=document.createElement('td');
496 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
497 td1.appendChild(
498 measurementcbo= document.createElement('select'),
499 measurementcbo.setAttribute('id','measurement'),
500<?php
501 $measure=mysql_query("SELECT*FROM measurement");
502 while($rowmeasure=mysql_fetch_array($measure))
503 {
504?>
505 measurementcbo.appendChild(
506 option=document.createElement('option'),
507 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
508 option.setAttribute('selected',true),
509 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
510 ),
511<?php
512 }
513?>
514 measurementcbo.setAttribute('id','measurement')
515 );
516 td1.appendChild(
517 button=document.createElement('input'),
518 button.setAttribute('type','button'),
519 button.setAttribute('value','[+]'),
520 button.setAttribute('id','btnAddTime'),
521 button.setAttribute('name','#table1'),
522 button.onclick=function(){
523 var aa;
524 $('div#TableHolder #table1 #Time').each(function(){
525 aa = $(this).val();
526 });
527
528 if(aa != ""){ timeValue = aa; name="name"; value="#table1"; meas = "hidden"; meas2 = true; getTableId = $(this).attr('name'); split2(); }else{ alert("please enter value for time to add measurement"); }
529
530
531 }
532 );
533 var td2=document.createElement('td');
534 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
535 td2.appendChild(
536 input = document.createElement('input'),
537 input.setAttribute('type','text'),
538 input.setAttribute('id','txtData')
539
540 );
541 var td4=document.createElement('td');
542 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
543
544 td4.appendChild(
545 button=document.createElement('input'),
546 button.setAttribute('type','button'),
547 button.setAttribute('value','Delete'),
548 button.setAttribute('id','btnDelete'),
549 button.onclick=function(){
550 $('#table1').remove();
551
552 }
553 );
554
555 tr.appendChild(td3);
556 tr.appendChild(td1);
557 tr.appendChild(td);
558
559 tr.appendChild(td2);
560 tr.appendChild(td4);
561 table.appendChild(tr);
562 div.appendChild(table);
563 $('#TableH1').append(div);
564
565
566 }
567 var meas;
568 var timeValue;
569 var pad;
570 if(cnt==0){ cnt=2; }
571 function split2()
572 {
573
574 cnt++;
575 var div= document.createElement("div");
576 div.setAttribute('id','TableHolder');
577 var table = document.createElement("table");
578 table.setAttribute('id',"table"+cnt);
579 table.setAttribute('width','100%');
580 table.setAttribute(name,value);
581 var tr = document.createElement('tr');
582 tr.setAttribute('id','');
583 tr.setAttribute('class','');
584
585 var td3=document.createElement('td');
586 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
587 td3.setAttribute('class','first');
588
589 td3.appendChild(
590 input = document.createElement("input"),
591 input.setAttribute("type","time"),
592 input.setAttribute("id","Time"),
593 input.setAttribute("max","24"),
594 input.setAttribute("min",'1'),
595 input.setAttribute("required",true),
596 input.setAttribute(meas,meas2),
597 input.setAttribute("value",timeValue)
598
599
600 );
601 td3.appendChild(
602 button=document.createElement('input'),
603 button.setAttribute('type','button'),
604 button.setAttribute('value','[+]'),
605 button.setAttribute('id','btnAddTime'),
606 button.setAttribute(meas,meas2),
607 button.setAttribute('name','#table'+cnt),
608
609 button.onclick=function(){
610 var aa;
611 $('div#TableHolder #table'+cnt+' #Time').each(function(){
612 aa = $(this).val();
613 });
614 bb = $(this).closest('table').attr('name');
615 if(aa != ""){var splitting = aa.split(':'); var add = 01;
616
617
618 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
619
620 function pad(number, length) {
621
622 var str = '' + number;
623 while (str.length < length) {
624 str = '0' + str;
625 }
626
627 return str;
628
629 }
630
631 var s = 0; var get;
632 var nn;
633 nn = bb;
634 $("table").each(function() {
635 if($(this).attr("name")==nn){
636
637 get = "#"+$(this).attr("id");
638 //get = $(this).attr("name");
639 s =1;
640 }else{
641 if(s==0){
642 get = '#table'+cnt;
643 }
644 }
645 });
646
647name="name"; value = bb;
648meas = "class"; meas2 = "time"; getTableId = get; split1(); }else{ alert("please enter value for time to add measurement"); }
649
650
651 }
652 );
653
654 var td=document.createElement('td');
655 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
656 td.appendChild(
657 sourcecbo= document.createElement('select'),
658 sourcecbo.setAttribute('id','source'),
659<?php
660 $source=mysql_query("SELECT*FROM source");
661 while($rowsource=mysql_fetch_array($source))
662 {
663?>
664 sourcecbo.appendChild(
665 option=document.createElement('option'),
666 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
667 option.setAttribute('selected',true),
668 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
669
670 ),
671<?php
672 }
673 ?>
674 sourcecbo.setAttribute('id','source')
675
676 );
677var td1=document.createElement('td');
678td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
679td1.appendChild(
680measurementcbo= document.createElement('select'),
681measurementcbo.setAttribute('id','measurement'),
682<?php
683 $measure=mysql_query("SELECT*FROM measurement");
684 while($rowmeasure=mysql_fetch_array($measure))
685 {
686?>
687measurementcbo.appendChild(
688option=document.createElement('option'),
689option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
690option.setAttribute('selected',true),
691option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
692 ),
693<?php
694 }
695?>
696 measurementcbo.setAttribute('id','measurement')
697 );
698 td1.appendChild(
699 button=document.createElement('input'),
700 button.setAttribute('type','button'),
701 button.setAttribute('value','[+]'),
702 button.setAttribute('id','btnAddTime'),
703 button.setAttribute('name','#table'+cnt),
704 button.onclick=function(){
705 var aa;
706 var bb;
707 $('div#TableHolder #table'+cnt+' #Time').each(function(){
708 aa = $(this).val();
709 });
710 bb = $(this).closest('table').attr('name');
711 if(aa != "")
712 {
713 name = "name";
714 value = bb;
715 // alert('2'+bb);
716 timeValue = aa;
717 meas = "hidden";
718 meas2 = true;
719 getTableId = $(this).attr('name');
720 split1();
721 }
722 else
723 {
724 alert("please enter value for time to add measurement");
725 }
726
727
728 }
729 );
730
731 var td2=document.createElement('td');
732 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
733 td2.appendChild(
734 input = document.createElement('input'),
735 input.setAttribute('type','text'),
736 input.setAttribute('id','txtData')
737
738 );
739 var td4=document.createElement('td');
740 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
741
742 td4.appendChild(
743 button=document.createElement('input'),
744 button.setAttribute('type','button'),
745 button.setAttribute('value','Delete'),
746 button.setAttribute('id','btnDelete'),
747 button.onclick=function(){
748 $('#table'+cnt).remove();
749 cnt--;
750 }
751 );
752
753 tr.appendChild(td3);
754 tr.appendChild(td1);
755 tr.appendChild(td);
756
757 tr.appendChild(td2);
758 tr.appendChild(td4);
759 table.appendChild(tr);
760 div.appendChild(table);
761 $(div).insertAfter($(getTableId));
762
763
764
765 }
766 function split1()
767 {
768
769 cnt++;
770 var div= document.createElement("div");
771 div.setAttribute('id','TableHolder');
772 var table = document.createElement("table");
773 table.setAttribute('id',"table"+cnt);
774 table.setAttribute('width','100%');
775 table.setAttribute(name,value);
776 var tr = document.createElement('tr');
777 tr.setAttribute('id','');
778 tr.setAttribute('class','');
779
780 var td3=document.createElement('td');
781 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
782 td3.setAttribute('class','first');
783 td3.appendChild(
784 input = document.createElement("input"),
785 input.setAttribute("type","time"),
786 input.setAttribute("id","Time"),
787 input.setAttribute("max","24"),
788 input.setAttribute("min",'1'),
789 input.setAttribute("required",true),
790 input.setAttribute(meas,meas2),
791 input.setAttribute("value",timeValue)
792
793 );
794 td3.appendChild(
795 button=document.createElement('input'),
796 button.setAttribute('type','button'),
797 button.setAttribute('value','[+]'),
798 button.setAttribute('id','btnAddTime'),
799 button.setAttribute(meas,meas2),
800 button.setAttribute('name','#table'+cnt),
801
802 button.onclick=function(){
803 var aa;
804 $('div#TableHolder #table'+cnt+' #Time').each(function(){
805 aa = $(this).val();
806 });
807 bb = $(this).closest('table').attr('name');
808 if(aa != ""){ var splitting = aa.split(':'); var add = 01;
809
810 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
811
812 function pad(number, length) {
813
814 var str = '' + number;
815 while (str.length < length) {
816 str = '0' + str;
817 }
818
819 return str;
820
821 }
822 var s = 0; var get;
823 var nn;
824 nn = bb;
825 $("table").each(function() {
826 if($(this).attr("name")==nn){
827
828 get = "#"+$(this).attr("id");
829 //get = $(this).attr("name");
830 s =1;
831 }else{
832 if(s==0){
833 get = '#table'+cnt;
834 }
835 }
836 });
837
838 name="name"; value=bb; meas = "class"; meas2 = "time"; getTableId = get; split1(); }else{ alert("please enter value for time to add measurement"); }
839
840
841 }
842 );
843
844 var td=document.createElement('td');
845 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
846 td.appendChild(
847 sourcecbo= document.createElement('select'),
848 sourcecbo.setAttribute('id','source'),
849<?php
850 $source=mysql_query("SELECT*FROM source");
851 while($rowsource=mysql_fetch_array($source))
852 {
853?>
854 sourcecbo.appendChild(
855 option=document.createElement('option'),
856 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
857 option.setAttribute('selected',true),
858 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
859
860 ),
861<?php
862 }
863 ?>
864 sourcecbo.setAttribute('id','source')
865
866 );
867 var td1=document.createElement('td');
868 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
869
870 td1.appendChild(
871 measurementcbo= document.createElement('select'),
872 measurementcbo.setAttribute('id','measurement'),
873<?php
874 $measure=mysql_query("SELECT*FROM measurement");
875 while($rowmeasure=mysql_fetch_array($measure))
876 {
877?>
878 measurementcbo.appendChild(
879 option=document.createElement('option'),
880 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
881 option.setAttribute('selected',true),
882 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
883 ),
884<?php
885 }
886?>
887 measurementcbo.setAttribute('id','measurement')
888 );
889 td1.appendChild(
890 button=document.createElement('input'),
891 button.setAttribute('type','button'),
892 button.setAttribute('value','[+]'),
893 button.setAttribute('id','btnAddTime'),
894 button.setAttribute('name','#table'+cnt),
895 button.onclick=function(){
896
897 var aa;
898 var bb;
899 $('div#TableHolder #table'+cnt+' #Time').each(function(){
900 aa = $(this).val();
901 });
902
903 bb = $(this).closest('table').attr('name');
904
905 if(aa != "")
906 {
907 name = "name";
908 value = bb;
909 //alert(value);
910 timeValue = aa;
911 meas = "hidden";
912 meas2 = true;
913 getTableId = $(this).attr('name');
914 split1();
915 }
916 else
917 {
918 alert("please enter value for time to add measurement");
919 }
920 }
921 );
922
923 var td2=document.createElement('td');
924 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
925 td2.appendChild(
926 input = document.createElement('input'),
927 input.setAttribute('type','text'),
928 input.setAttribute('id','txtData')
929
930 );
931 var td4=document.createElement('td');
932 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
933
934 td4.appendChild(
935 button=document.createElement('input'),
936 button.setAttribute('type','button'),
937 button.setAttribute('value','Delete'),
938 button.setAttribute('id','btnDelete'),
939 button.onclick=function(){
940 $('#table'+cnt).remove();
941 cnt--;
942 });
943
944 tr.appendChild(td3);
945 tr.appendChild(td1);
946 tr.appendChild(td);
947
948 tr.appendChild(td2);
949 tr.appendChild(td4);
950 table.appendChild(tr);
951 div.appendChild(table);
952 $(div).insertAfter($(getTableId));
953 }
954
955 //$('div#TableHolder #table'+cnt+' #Time')
956
957
958 // $('div#TableHolder table #Time').keyup(function(){
959
960 // if($('div#TableHolder #table2 #Time').val() <= 0 || $('div#TableHolder #table1 #Time').val() <=0){
961
962
963 // }else{
964 // if($('div#TableHolder #table1 #Time').val() <= $('div#TableHolder #table2 #Time').val()){
965 // alert(cnt);
966 // }
967 // }
968 // });
969
970
971
972
973
974 });
975 </script>
Note: See TracBrowser for help on using the repository browser.