Hello everyone,
I am building an offline application using sqlite on phonegap, and my Jquery versions are 1.2 for mobile and 1.8. My code did not work, i don't know if this is the right way to store date into database. The timeFunction is called on 4 different buttons depending on which button the user clicks. For example, if morning button is clicked and then the the ok button which calls the timeFunction is cliked, i wouls like the data to be stored in the morning column. Below are both codes. The first one stores date and time into the sqlite table while the second stores the time the user inputs into the table. Please, i need help on how to do this and how to create alarm when it is time.
- function dateFunction(){
- //insert a record for time and date, called when clicked(save/ submit) a btn.
-
- var d = new Date();
- dt = d.setFullYear($('year').val()),d.setMonth($('month').val()), d.setDate($('day').val());
- dt.format("yyyy/mm/dd");
- if(dt!="" && dt==true){
- db.transaction(function (tx)
- { tx.executeSql(insertStatement, [Date], loadAndReset, onError); });
-
- }
- }
- function timeFunction(){
-
- var hourMinute= new Date().setHours($('#hour').val())+":"+ new Date().setMinutes($('#minute').val());
-
- if(hourMinute !="" && $('#hour').val()>=5&&$('#hour').val()<=12)
- {
- db.transaction(function (tx) {
- tx.executeSql(insertStatement,
- [morningTime], loadAndReset, onError); });
- }
-
- if(hourMinute !="" && $('#hour').val()>=12&&$('#hour').val()<=17)
- {
- db.transaction(function (tx) {
- tx.executeSql(insertStatement,
- [afternoonTime], loadAndReset, onError); });
- }
-
- if(hourMinute !="" && $('#hour').val()>=18&&$('#hour').val()<=20)
- {
- db.transaction(function (tx) {
- tx.executeSql(insertStatement,
- [eveningTime], loadAndReset, onError); });
- }
-
- if(hourMinute !="" && $('#hour').val()>=21&&$('#hour').val()<=23)
- {
- db.transaction(function (tx) {
- tx.executeSql(insertStatement,
- [nightTime], loadAndReset, onError); });
- }
- }