function checkLimit()
{
db=openDatabase(masterDbName,version,displayName,maxSize);
db.transaction(function(transaction)
{
var active=localStorage.getItem("ActiveProject");
var query='Select projdb_id from projecttable where proj_name="'+active+'"';
transaction.executeSql(query, [] , function(transaction, result)
{
if(result != null && result.rows != null)
{
if (result.rows.length != 0)
{
for (var i = 0; i < result.rows.length; i++)
{
var row = result.rows.item(i);
id=row.projdb_id;
}
}
}
db1=openDatabase(id,version,displayName,maxSize);
db1.transaction(function (t)
{
var query='Select * from customer where cust_name="'+document.getElementById('name').value+'"';
t.executeSql(query, [] , function(t, result)
{
if(result != null && result.rows != null)
{
if (result.rows.length != 0)
{
for (var i = 0; i < result.rows.length; i++)
{
var row = result.rows.item(i);
var period=row.credit_period;
}
var myDate=new Date(document.getElementById('date').value),
curr_month=("0"+(myDate.getMonth()+1)).slice(-2),
day=("0"+myDate.getDate()).slice(-2);
}
}
var queryIn = 'SELECT date_format FROM params ';
var listArry =[];
db.transaction(function (tx)
{
tx.executeSql(queryIn, [], function (tx, results)
{
var len = results.rows.length, i;
if(results != null && results.rows != null)
{
if (results.rows.length != 0)
{
for (var i = 0; i < results.rows.length; i++)
{
var row = results.rows.item(i);
var dateformat=row.date_format;
}
var formDate;
if(dateformat=="dd/mm/yyy")
{
formDate= day+"/"+curr_month + "/" +myDate.getFullYear();
}
else
{
formDate= curr_month+"/"+myDate + "/" +myDate.getFullYear();
}
}
}
var dated=formDate.getDate()+period;
expDate = dated;
document.getElementById('due_date').value=expDate;
});
});
});
});
});
});
}
This is my code to get the format of the date and calculate the credit period and display the date according to that in textbox.I have a date field from where the user will enter the date and according to the date entered the due_date field should change by addding the credit period value..
for example if the date is 03/06/2014 and the credit limit is 10 days...then 13/06/2014 should be the due date value..
How can I do this....The above code var dated=formDate.getDate()+period; shows the error undefined function..
Plz help!!!