我正在使用 css 开发一个按钮,我使用 SQLite 和 jquery 来构建 OnClick 事件,但查询不起作用。单击 id="gameLogin" 的按钮后,我想在表联系人。运行数据库并创建表后,
有什么想法吗?还有其他解决方案吗?
非常感谢
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SQL Storage</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<br/><br/>
<div align="center">
<section id="gameIntro">
First name:<input type="text" id="firstName"/><br/>
<p><a id="gameLogin" class="button3 blue medium" href="game.html">Login</a>
</p>
</section>
</div>
</body>
<script>
var results = document.getElementById('results');
//var id = document.getElementById('id');
var firstName = document.getElementById('firstName');
var createStatement = "CREATE TABLE IF NOT EXISTS Contacts (firstName TEXT PRIMARY KEY )";
var selectAllStatement = "SELECT * FROM Contacts";
var insertStatement = "INSERT INTO Contacts (firstName) VALUES (?)";
var updateStatement = "UPDATE Contacts SET firstName = ?, WHERE firstName = ?";
var deleteStatement = "DELETE FROM Contacts WHERE firstName=?";
var dropStatement = "DROP TABLE Contacts";
var findStatement = "SELECT * FROM Contacts WHERE firstName=?";
var db = openDatabase("AddressBook", "1.0", "Address Book", 200000);
var dataset;
createTable();
$("#gameLogin").click( function(){
db.transaction( function(tx) {tx.executeSql(insertStatement,[firstName.value],onErrorLogIn,goplay); });
});
.......... .........