source: schedule/function/function.php@ 16926

Last change on this file since 16926 was 16926, checked in by tanio, 11 years ago
File size: 2.9 KB
Line 
1 <div id="saving">
2
3 <script type="text/javascript">
4 $(document).ready(function GetDate(day ,month ,year){
5 // for fupdate
6 <?php
7
8
9
10 $cntsource=mysql_query("SELECT COUNT(*) as `SourceID` FROM source");
11 $rowcnt=mysql_fetch_array($cntsource);
12 $Total= $rowcnt['SourceID'];
13 ?>
14 $('#save').click(function(){
15var dtr;
16 dtr = '<?php
17
18 if(isset($_GET['days'])){
19 echo $_GET['days'];
20 }
21 else
22 {
23
24 echo date("Y-m-d");
25
26 }
27
28 ?>';
29
30 var InputValue = [];
31 var selectedSource = [];
32 var selectedTime = [];
33 var selectedMeasurement = [];
34 var Time;
35 var Source;
36 var measure;
37 var value;
38 var checks = 0;
39 for(var i=1;i <= cnt;i++)
40 {
41 if($('#Time'+i).val() != '')
42 {
43 Time=$('#Time'+i).val();
44 Source=$('select[id="source'+i+'"]').val();
45 measure=$('select[id="measurement'+i+'"]').val();
46 value=$('#txtData'+i).val();
47 selectedMeasurement.push(measure);
48 selectedSource.push(Source);
49 selectedTime.push(Time);
50 InputValue.push(value);
51
52 }
53 else
54 {
55 checks++;
56
57 }
58 }
59 if(checks == 0)
60 {
61 alert(dtr);
62 $.ajax({
63 type: "POST",
64 cache: false,
65 url: "Transaction/insert.php",
66 data: "Time="+selectedTime+'&Source='+selectedSource+'&measure='+selectedMeasurement+'&Data='+InputValue+'&Date='+dtr,
67 dataType: "json",
68 success: function(data) {
69 alert('Success: The text is now stored in the database.');
70 }
71 });
72 //window.location = 'Transaction/insert.php?Time='+selectedTime+'&Source='+selectedSource+'&measure='+selectedMeasurement+'&Data='+InputValue+'&Date='+dtr;
73 }
74 else
75 {
76
77 alert("Please fill all the details!");
78 }
79 });
80
81
82
83
84
85
86
87
88
89
90
91 $('#update').click(function()
92 {
93 //alert(dtr);
94 var InputValue = [];
95 var selectedSource = [];
96 var selectedTime = [];
97 var selectedMeasurement = [];
98 var Time;
99 var Source;
100 var measure;
101 var value;
102 var checks = 0;
103 for(var i=1;i <= cnt;i++)
104 {
105 if($('#Time'+i).val() != '')
106 {
107 Time=$('#Time'+i).val();
108 Source=$('select[id="source'+i+'"]').val();
109 measure=$('select[id="measurement'+i+'"]').val();
110 value=$('#txtData'+i).val();
111 selectedMeasurement.push(measure);
112 selectedSource.push(Source);
113 selectedTime.push(Time);
114 InputValue.push(value);
115
116 }else{
117 checks++;
118
119 }
120 }
121
122 if(checks == 0)
123 {
124
125 $.ajax({
126 type: "POST",
127 cache: false,
128 url: "Transaction/update.php",
129 data: "Time="+selectedTime,
130 dataType: "json",
131 success: function(data) {
132 alert('Success: The text is now stored in the database.');
133 }
134 });
135 //window.location = 'Transaction/update.php?Time='+selectedTime+'&Source='+selectedSource+'&measure='+selectedMeasurement+'&Data='+InputValue+'&Date='+dtr;
136 }
137 else
138 {
139
140 alert("Please fill all the details!");
141 }
142 });
143
144
145
146
147
148
149
150
151 });
152 </script>
153 </div>
Note: See TracBrowser for help on using the repository browser.