我正在開發一個使用css的按鈕,並且我使用SQLite和jquery來構建OnClick事件,但查詢無法正常工作。點擊id =「gameLogin」後,我想要將輸入字段firstName的值插入表格Contacts中。運行數據庫和表創建後,使用jquery和SQLite的CSS按鈕OnClick事件
有什麼想法嗎?有另一種解決方案嗎?
謝謝各位大大
<!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); });
});
.......... .........
WOW,你知道這個過程有多可笑嗎?嘗試把所有的SQL調用在PHP和編碼數據發送到您的控制器 – SpYk3HH 2012-04-19 18:08:39
Downvoted,直到你接受過去的問題的答案。 – Ohgodwhy 2012-04-19 18:21:28