Web SQL Database storing user settings - inserting and query issues!

Im building an app with Cordova/phonegap and im using Web SQL as my database engine. The database will hold an id for the user, county, gender, age and a multiple choice.

But my lack of SQL skills, have given me some trouble. Ive managed to create the database and table with these lines:

onDeviceReady: function() {
    app.db = window.openDatabase("Database", "1.0", "My user DB", 200000);

Then i have a testIfDatabaseExists() function to see if should create Database or make a query. if create (im also inserting 2 test users into the database):

createDatabase: function() {
    app.db.transaction(app.populateDB, app.populateError, app.populateSuccess);

populateDB: function(tx) {
    tx.executeSql('DROP TABLE IF EXISTS USERS');
    tx.executeSql('CREATE TABLE IF NOT EXISTS USERS (id unique, poll, county, gender, age)');
    tx.executeSql('INSERT INTO USERS (id, poll, county, gender, age) VALUES (1, "V", "Fyn", "Male", 25)');
    tx.executeSql('INSERT INTO USERS (id, poll, county, gender, age) VALUES (2, "S", "KBH", "Male", 35)');

From here Im having trouble with inserting the data inputs from the app user and also update the old user inputs with its old settings with the database query. Right now im just executing the query out into html with innerHTML to check if the query works. Ive tried having a onClick event on my submit button: AddValueToDB() - but i cant seem to make it do anything :confused:

AddValueToDB: function() {
 if (!window.openDatabase) {
     alert('Databases are not supported in this browser.');

 tx.executeSql('INSERT INTO USERS(id, poll, county, gender, age) VALUES (?,?,?,?,?)',[$('#txId').val(), $('#txPoll').val(), $('#txCounty').val(), $('#txGender').val(), $('#txAge').val()], app.populateError);

My HTML form:

    <label for="id">Username/ID:</label>
    <input type="number" name="ID" id="txId" value="" />
    <label for="county">County:</label>
    <input id="txCounty" type="text" name="county" id="county" value="" placeholder="County" />
    <fieldset data-role="controlgroup" data-type="horizontal" id="txGender">
         <input type="radio" name="radio-choice-h-2" id="radio-choice-h-2a" value="male" checked="checked">
         <label for="radio-choice-h-2a">Male</label>
         <input type="radio" name="radio-choice-h-2" id="radio-choice-h-2b" value="female">
         <label for="radio-choice-h-2b">Female</label>
    <label for="age">Age:</label>
    <input type="number" name="age" id="txAge" value="" placeholder="Age" />

    <input type="button" value="Add record" onClick="AddValueToDB()">
    <input type="button" value="Refresh" onClick="ListDBValues()">


OPDATE: What I need some help with, is updating the row for the user, when the settings are changed:county, gender, ageā€¦ - my AddValueToDB() function doesnt work.
Also outputting the user values into the input fields, I could use some guidance for! :slight_smile: