JavaScript Insert a value into SQL local database and print the tables data using Javascript insert value into table sql,insert value into array,insert

I have a form which uses html and javascript to submit data into a table of an SQL database. So I want to submit what is typed from the user to a local SQLite database that is inside his device. I am using PhoneGap so I can only use HTML, JavaScript ans CSS. I have the data inserted with a value called SubmVal . I want to insert that value into a table called TEST and has just two fields [id INT NOT NULL-name VARCHAR]. I use this code:

var db = window.openDatabase("Database", "1.0", "Cordova TEST", 20000);
db.transaction(populateDB, errorCB, successCB);

function SubmitButton() {
    /*
    CODE TO GET THE INSERTED DATA
    */
    var SubmVal = submitteddata;
    if (confirm('Are you sure you want to save this ' + SubmVal + ' into the database?')) {
                 function populateDB(tx) {
                 tx.executeSql('INSERT INTO TEST (id, name) VALUES (1, SubmVal)');
                 }
                 alert("Succesfully Inserted");
    } else {
                 alert("Cancelled");
    }

}

So I have 3 questions: 1. How to get the SubmVal into the second field of the table? I am pretty sure this one doesn't work:

tx.executeSql('INSERT INTO TEST (id, name) VALUES (1, SubmVal)');

2. How to get this populateDB(tx) function working, like a physical continuation(not to press other buttons or stuff). Do I need to change the code like this:

if (confirm('Are you sure you want to save this ' + SubmVal + ' into the database?')) {
                     tx.executeSql('INSERT INTO TEST (id, name) VALUES (1, SubmVal)');}

3. How can I print every single line of the table using a function?

I made the question a bit more general in order to help as many as possible people who have the same problem. Thanks in advance.

Answer:1

http://jsfiddle.net/PhilFromHeck/KzSxT/ In this fiddle, you can see at line 38 in the Javascript that I've attempted to make a comparison that isn't working. I believe it because one of the variables ...

http://jsfiddle.net/PhilFromHeck/KzSxT/ In this fiddle, you can see at line 38 in the Javascript that I've attempted to make a comparison that isn't working. I believe it because one of the variables ...

  1. javascript compare objects in array
  2. javascript compare objects for equality
  3. javascript compare objects by value
  4. javascript compare objects difference
  5. javascript compare objects by reference
  6. javascript compare objects by keys
  7. javascript compare objects es6
  8. javascript compare objects lodash
  9. javascript compare objects properties
  10. javascript compare objects
  11. javascript compare objects ignore property
  12. javascript compare objects stringify
  13. javascript compare objects shallow
  14. javascript compare objects hash
  15. javascript compare objects json
  16. javascript compare objects fast
  17. javascript compare objects online
  18. javascript compare objects greater than
  19. javascript compare objects npm
  20. javascript compare objects for identity

I need to use an Image instead of using dropbox default chooser button. I have gone through their API docs and I couldn't find any such ways to use other elements for dropbox chooser. Can anyone ...

I need to use an Image instead of using dropbox default chooser button. I have gone through their API docs and I couldn't find any such ways to use other elements for dropbox chooser. Can anyone ...

For my highchart, I want to set maximum value of 100 and minimum value of 1. When I try to code like this, it outputs is 0-100 not 1-100. If I change or remove max range, it works fine for small ...

For my highchart, I want to set maximum value of 100 and minimum value of 1. When I try to code like this, it outputs is 0-100 not 1-100. If I change or remove max range, it works fine for small ...

We have Node.js as a server which helps in getting us remote rest service, from client html I am trying to get response headers from the jQuery Ajax call using below code: $.ajax({ type: "get", ...

We have Node.js as a server which helps in getting us remote rest service, from client html I am trying to get response headers from the jQuery Ajax call using below code: $.ajax({ type: "get", ...