Can anyone help me how to use reload or not to use reload to display the updated value of the table..? My code is
function save()
{ var v=0;
//alert("save button");< br />// alert("global :"+global.length);
for(var n=0;n<(global.length+l);n++)
{
/ /alert("hi");
var x1=$('input.current')[n];
//alert($(x1).val());
if ($(x1).val()=="0")
{
// alert("compare");
var y1=$('input.new')[n ];
newaloc[v]=$(y1).val();
//alert(newaloc[v]);
v++;
}< br /> }
//var polno=init();
var db = window.openDatabase("DataBase", "3.6.22", "test", 200000);< br />
db.transaction(function(transaction)
{
transaction.executeSql('SELECT * FROM POLICIES_DET WHERE POLICY_NUMBER="' +polno+'";',[],
function(transaction, result)
{
if (result != null && result.rows != null)
{
// alert(result.rows.length);
for (var i = 0; i{
var row = result.rows.item(i);
// $("#table").append(""); "+row.FUND_DESC+" td>
fund=row.INSURED_AMOUNT;
//alert(fund);
}
}
},errorHandler);
},errorHandler,nullHandler);
db.transaction(insert, errorCB, successCB);
al//ert( "after insert");
//alert("no of records:"+gl obal.length);
for(var i=0;i{
var it=$('input.new')[i];
var k=$(it).val();
//if(k.length>0)
//{
// alert("new allocation loop");
xx.push(k);
//alert(xx[v]);
v++;
// }
}
v=0 ;
db.transaction(function(transaction)
{
// alert("updation");
for(var j=0;j{
var c=xx[j];
//alert(c);
var g=global[j];
//alert(g) ;
if(c.length>0)
{
var vl=fund*(c/100);
//alert(vl);
transaction. executeSql('UPDATE FUND_DET SET ALLOC_PERCNT="'+c+'",FUND_VALUE="'+vl+'"WHERE POLICY_NUMBER="'+polno+'"AND FUND_DESC="'+g+'";',[],
function(transaction, result)
{
if (result != null && result.rows != null)
{
//al ert("Test other way");
for (var i = 0; i{
var row = result.rows.item(i) ;
}
}
},errorHandler);
}} },errorHandler,nullHandler);
< br />location.reload();
}
Like this
db.transaction(function(transaction)
{
/ / alert("updation");
for(var j=0;j{
var c=xx[j];
// alert(c);
var g=global[j];
//alert(g);
if(c.length>0)
{
var vl=fund*(c/100);
//alert(vl);
transaction.executeSql('UPDATE FUND_DET SET ALLOC_PERCNT="'+c+'",FUND_VALUE="'+vl+'" WHERE POLICY_NUMBER="'+polno+'"AND FUND_DESC="'+g+'";',[],
function(tra nsaction, result)
{
if (result != null && result.rows != null)
{
//alert("Test other way");
for (var i = 0; i{
var row = result.rows.item(i);
}
}
location.reload();
},errorHandler);
}} },errorHandler,nullHandler);
}
I am updating the table value, and then I want to display the updated table value in phonegap. For this, I am using the reload() method, but when I use In this method, the table is not updated (the code related to the database is not executed), but is being reloaded.
Can anyone help me how to use reload or not to use reload to display the updated value of the table..? My code is
function save()
{ var v=0;
//alert("save button");< br />// alert("global :"+global.length);
for(var n=0;n<(global.length+l);n++)
{
/ /alert("hi");
var x1=$('input.current')[n];
//alert($(x1).val());
if ($(x1).val()=="0")
{
// alert("compare");
var y1=$('input.new')[n ];
newaloc[v]=$(y1).val();
//alert(newaloc[v]);
v++;
}< br /> }
//var polno=init();
var db = window.openDatabase("DataBase", "3.6.22", "test", 200000);< br />
db.transaction(function(transaction)
{
transaction.executeSql('SELECT * FROM POLICIES_DET WHERE POLICY_NUMBER="' +polno+'";',[],
function(transaction, result)
{
if (result != null && result.rows != null)
{
// alert(result.rows.length);
for (var i = 0; i{
var row = result.rows.item(i);
// $("#table").append(""); "+row.FUND_DESC+" td>
fund=row.INSURED_AMOUNT;
//alert(fund);
}
}
},errorHandler);
},errorHandler,nullHandler);
db.transaction(insert, errorCB, successCB);
al//ert( "after insert");
//alert("no of records:"+globa l.length);
for(var i=0;i{
var it=$('input.new')[i];
var k=$(it).val();
//if(k.length>0)
//{
// alert("new allocation loop");
xx.push(k);
//alert(xx[v]);
v++;
// }
}
v=0 ;
db.transaction(function(transaction)
{
// alert("updation");
for(var j=0;j{
var c=xx[j];
//alert(c);
var g=global[j];
//alert(g) ;
if(c.length>0)
{
var vl=fund*(c/100);
//alert(vl);
transaction. executeSql('UPDATE FUND_DET SET ALLOC_PERCNT="'+c+'",FUND_VALUE="'+vl+'"WHERE POLICY_NUMBER="'+polno+'"AND FUND_DESC="'+g+'";',[],
function(transaction, result)
{
if (result != null && result.rows != null)
{
//alert ("Test other way");
for (var i = 0; i{
var row = result.rows.item(i);
}
}
},errorHandler);
}} },errorHandler,nullHandler);
location.reload();
}
When I write the location in the function.reload() it works fine
Like this
db.transaction(function(transaction)
{
// alert("updation");
for (var j=0;j{
var c=xx[j];
//alert(c);
var g=global [j];
//alert(g);
if(c.length>0)
{
var vl=fund*(c/100);
//alert(vl);
transaction.executeSql('UPDATE FUND_DET SET ALLOC_PERCNT="'+c+'",FUND_VALUE="'+vl+'"WHERE POLICY_NUMBER="'+polno+'"AND FUND_DESC=" '+g+'";',[],
function(transaction, result)
{
if (result != null && result.rows != null)
{
//alert("Test other way");
for (var i = 0; i{
var row = result.rows.item(i);
}
}
location. reload();
},errorHandler);
}} },errorHandler,nullHandler);
}