如何从一个html页面值传递到PhoneGap的另一个HTML页面? [英] how to pass values from one html page to the other html page in PHONEGAP?

查看:144
本文介绍了如何从一个html页面值传递到PhoneGap的另一个HTML页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经寻找这个答案,我得到了2样的答复,我发现我可以实现它。

i have searched for this answer and i got 2 sort of replies,which i found i could implement it.

他们..

window.location.href=href='2ndpage.html?var id=results.rows.item(1).id';

* results.rows.item(1).id- 这个我从数据库中获取它的价值---这将是在DB元素的id的值。

获得的价值,我实现了这个code ..

to get the value,i implemented this code..

 function onDeviceReady() 
    {var db =  window.sqlitePlugin.openDatabase("Database", "1.0", "Database",1000000); 
     console.log("processing onDeviceReady");
     db.transaction(getParameter,queryDB,errorCB);  
    }           

    function getParameter(paramName) 
    {   console.log("processsinggg parameter loop ");
    var searchString = window.location.search.substring(1),
        i, val, params = searchString.split("&");

         for (i=0;i<params.length;i++) {
                val = params[i].split("=");
            if (val[0] == paramName) {
            return unescape(val[1]);
        }
    console.log("valueeesss: "+val[1]);

  }return null;
}

IT流程,直到这个循环并停止思考...我还没有叫叫queryDB(其他functions..i);

当它处理queryDB在code

when it processed queryDB in the code

function queryDB(tx) 
{       tx.executeSql('SELECT * FROM table_name', [], querySuccess, errorCB);
        console.log("processing queryDB");
}

它说,作为TX不defined..whereas它只是一个参数

it says as tx is not defined..whereas its just a parameter

我试图打印输出... O / P是..

i tried printing the output...o/p was..

results.rows.item(1).id

由于我的失误,我发现很难实现它... 或许可以too..but ....

which i found difficult implementing it...probably could be because of my mistake too..but....

另一种方法我想是在 FORM方法

<form name="2ndpart"  method="post">
id: <input type="hidden" name="id">
<input type="submit" value="results.rows.item(0).id">
</form> 

,并在第二页,我给

and in the second page,i gave

function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(m,key,value) {
    vars[key] = value;
});
return vars;

}

也没有去第二页它self..as它说的是不是一个函数。

it did not go the 2nd page it self..as it said was not a function.

这是正确的方法和最容易实现的?

which is the right method and the easiest to implement?

推荐答案

这是我们如何将值从一个HTML到PhoneGap的另一个HTML页面

This is how we pass values from one html to another html pages in PHONEGAP

        function test()
        {
            window.location.href="index.html?var id=1";
        }

        <div id="test"><img src="img/test.png" onClick="test()"/></div>

这篇关于如何从一个html页面值传递到PhoneGap的另一个HTML页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆