Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.addEventListener("deviceready", onDeviceReady, false);
- function onDeviceReady() {
- populateDB();
- }
- function populateDB() {
- var db = window.openDatabase("Database","1.0","My Database, 20000);
- db.transaction(populate_DB, errorCB, successCB);
- }
- function populate_DB(tx) {
- tx.executeSql('CREATE TABLE IF NOT EXISTS Options (ID INTEGER UNIQUE NOT NULL, Name TEXT NOT NULL, Value INTEGER NOT NULL)');
- tx.executeSql('CREATE TABLE IF NOT EXISTS Questions (ID INTEGER UNIQUE NOT NULL, Question TEXT NOT NULL, Answer TEXT)');
- tx.executeSql('INSERT OR IGNORE INTO Options (ID, Name, Value) VALUES (1, "License", 0)');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (0, "Age","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (1, "two","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (2, "three","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (3, "four","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (4, "five","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (5, "six","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (6, "seven","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (7, "eigth","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (8, "nine","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (9, "ten","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (10, "eleven","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (11, "twelve","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (12, "thirteen","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (13, "fourteen","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (14, "fifteen","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (15, "sixteen","")');
- tx.executeSql('INSERT OR IGNORE INTO Questions (ID, Question, Answer) VALUES (16, "seventeen","")');
- function age_save() {
- var db = window.openDatabase("Database","1.0","My Database", 20000);
- loc = "q_sex.html";
- db.transaction(age_query, errorCB);
- //Query Database
- function age_query(tx) {
- var age = document.getElementById("a_age").value;
- tx.executeSql('UPDATE Questions SET Answer = "'+age+'" WHERE ID="0";', [], q_querySuccess, errorCB);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement