Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reloading the page in phonegap

Tags:

cordova

I am updating the table values and then I want to display the updated table values in phonegap. For that I'm using the reload() method but when I am using this method the table is not updating (the code related to the database is not executing) but reloading is happening. Can anyone please help me how to display the updated values of table using reload or not using reload..? My code is

function save()
{ var v=0;
    //alert("save button");
//  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++;
       }
     }
    //var polno=init();

    var db = window.openDatabase("DataBase", "3.6.22", "test", 200000);



    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 < result.rows.length; i++)
                     {

                      var row = result.rows.item(i); 

                      //    $("#table").append("<tr><td class='fund'>"+row.FUND_DESC+"</td><td><input type='text' class='current' value='"+row.ALLOC_PERCNT+"' size='5' /></td><td><input type='text' class='new' value='"+row.FUND_VALUE+"' size='5' /></td><td><input type='text'class='new' size='5' /></td></tr>");                                              
    fund=row.INSURED_AMOUNT;
    //alert(fund);

                         }

                           }

                 },errorHandler); 
          },errorHandler,nullHandler);
    db.transaction(insert, errorCB, successCB);

    al//ert("after insert");


    //alert("no of records:"+global.length);
    for(var i=0;i<global.length;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<xx.length;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 < result.rows.length; i++)
                     {
                       var row = result.rows.item(i); 

                   }

                   }

                },errorHandler); 
        }}  },errorHandler,nullHandler);

location.reload();
         }
like image 329
Hima Avatar asked Nov 13 '22 22:11

Hima


1 Answers

You can use :-

window.location.reload(true);
like image 110
taruna-systematix Avatar answered Feb 26 '23 11:02

taruna-systematix