0

我已经启动并运行了数据库,并且我有一个下拉列表,我想用数据库中的条目填充。

我还没有找到办法,所以任何朝着正确方向的轻推都会很棒。我根本不是 Web 开发人员,但我得到了一个 Web 项目。:秒

我正在使用 html5 和 javascript。

<!DOCTYPE html>
<html>
<head>
    <title>TestTest</title>
    <script>var newdb = openDatabase('mydb3', '1.02', 'Test DB1', 100 * 1024 * 1024);
var msg;
newdb.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "Item 1")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "Item 2")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (4, "Item 3")');
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (5, "Item 4")');
msg = '<p>Log message created and row inserted.</p>';
document.querySelector('#status').innerHTML =  msg;
});

newdb.transaction(function (tx) {
tx.executeSql('SELECT * FROM LOGS', [], function (tx, results) {
var len = results.rows.length, i;
msg = "<p>Found rows: " + len + "</p>";
document.querySelector('#status').innerHTML +=  msg;
for (i = 0; i < len; i++){
  msg = results.rows.item(i);
  document.querySelector('#status').innerHTML +=  msg;
  document.getElementById("Select1").options.add(msg);
 }
}, null);
});

<div id="list" style="margin-top:5px;margin-left:5px;width:100px;">
   <select name="drop1" form="List" id="Select1" size="13" onchange="playAlert(this)">
       <option value="1111111">Field Number item 1</option>
   </select>

</div>
4

0 回答 0