source: schedule/js/function.js@ 17011

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