source: schedule/js/function.js@ 16915

Last change on this file since 16915 was 16915, checked in by tanio, 11 years ago
File size: 2.3 KB
Line 
1// This module prepare by : Jaypee Tanio
2// June 16, 2013
3
4function GetDate()
5{
6 $('#save').click(function(){
7 Time = [];
8 Data = [];
9 Source = [];
10 Measure = [];
11 Table = [];
12 $('div#TableHolder table').each(function(){ // call all the id of the table inside div#TableHolder
13 id=$(this).attr('id'); //Getting all id's
14 Time.push('#'+id+' input#Time'); // Storing id's of each element
15 Data.push('#'+id+' input#txtData');
16 Source.push('#'+id+' select#source :selected');
17 Measure.push('#'+id+' select#measurement :selected');
18 Table.push(id);
19 });
20 GetSaveData(Time,Data,Source,Measure); // Function call of saving the data
21 alert(Table);
22 });
23
24};
25
26
27function GetSaveData(Time,Data,Source,Measure){
28 var checks=0;
29 TimeSave = [];
30 DataSave = [];
31 SourceSave = [];
32 MeasureSave = [];
33 for(i=0;i<$('div#TableHolder table').length;i++)
34 {
35 $(Time[i]).each(function(){
36 TimeSave.push($(this).val()); // extracting each data into a value
37 });
38 $(Data[i]).each(function(){
39 DataSave.push($(this).val()); // extracting each data into a value
40 });
41 $(Source[i]).each(function(){
42 SourceSave.push($(this).val()); // extracting each data into a value
43 });
44 $(Measure[i]).each(function(){
45 MeasureSave.push($(this).val()); // extracting each data into a value
46 });
47 }
48 if($('#save').val()=='UPDATE')
49 {
50 if(checks == 0)
51 {
52 $.ajax({
53 type: "POST",
54 cache: false,
55 url: "Transaction/update.php",
56 data: "Time="+TimeSave+'&Source='+SourceSave+'&measure='+MeasureSave+'&Data='+DataSave+'&Date='+year+'-'+month+'-'+day, //posting the data to save
57 success: function(data) {
58
59 alert('Successfully Updated ! '+year+'-'+month+'-'+day);
60
61 }
62 });
63 }
64 else
65 {
66
67 alert("Please fill all the details!");
68 }
69 }
70 else
71 {
72 if(checks == 0)
73 {
74 $.ajax({
75 type: "POST",
76 cache: false,
77 url: "Transaction/insert.php",
78 data: "Time="+TimeSave+'&Source='+SourceSave+'&measure='+MeasureSave+'&Data='+DataSave+'&Date='+year+'-'+month+'-'+day, //posting the data to save
79 success: function(data) {
80
81 alert('Successfully added ! '+year+'-'+month+'-'+day);
82
83 }
84 });
85 }
86 else
87 {
88
89 alert("Please fill all the details!");
90 }
91
92 }
93
94};
Note: See TracBrowser for help on using the repository browser.