如何将从数据库中检索的数据设置为div内容?

时间:2013-04-18 12:58:51

标签: javascript listview cordova

编码检索数据..

脚本

 function querySuccess(tx, results) 
            {
                    var len = results.rows.length;
                    console.log("DEMO table: " + len + " rows found.");
                    for (var i=0; i<len; i++)
                    {
                        console.log("Row = " + i + " name= " + results.rows.item(i).name+ " address=  " + results.rows.item(i).address+ " roll_no= " + results.rows.item(i).roll_no);
                        document.getElementById("list_view").innerhtml  = results.rows.item(i).name;
                    }
            }

HTML

 <div id="list_view" style="float:left; width:100%; padding:0px; margin:0px;">
                <ul style="float:left; width:100%; list-style:none; padding:0px; margin:0px;">
                    <div style=" border-bottom-color:#CCCCCC; border-bottom:ridge; "> <li style="font-size:18px"></li></div>
                </ul>
            </div>
    </body>
</html>

AM I CORRECT ?? * 如何将从数据库中检索的数据设置为div内容? *

1 个答案:

答案 0 :(得分:2)

document.getElementById("list_view").innerhtml  = results.rows.item(i).name;

变为

document.getElementById("list_view").innerHTML  = results.rows.item(i).name;

P.S。我明白了

<divid="list_view"...>

也许这只是SO上的偶然错误,但是试着检查'id'是否与'div'分开而不是'divid'