I have a prepopulated HTML5 database that is formed via JavaScript. The user taps the button to decide which db information he wants to see.
Here is the form:
<form id="formBodyStyle">
<input type="button" class="buttonClass" id="buggy" value="Buggy" onclick ="onDeviceReady();">
<input type="button" class="buttonClass" id="shortCourse" value="Short Course" onclick ="onDeviceReady();">
<input type="button" class="buttonClass" id="all" value="All" onclick ="onDeviceReady();">
</form>
“onDeviceReady()” starts the chain of setting up the database. Here is the section where the db query is supposed to be formed with the above chosen value:
function queryDB(tx) {
console.log("3. function queryDB(tx)");
var bodyStyle = document.getElementById('formBodyStyle');
var chosenBody = bodyStyle.value;
var result = "(bodyType === chosenBody)"; // form the WHERE clause
if (chosenBody == undefined) { result = 1 }; // show the whole db on startup
if (chosenBody == "All") { result = 1 }; // show the whole db with "All" button
tx.executeSql("SELECT * FROM 'CARS' WHERE result", [], querySuccess, errorCB);
}
However, the console feedback I get is:
3. function queryDB(tx) storage.html:36
Error processing SQL: Code undefined
… and the line number is not specified for the failure point.
Can you tell me how to set the button value as a database variable?
I posted this in the JavaScript thread and not PHP because it is JS code used in an HTML5 database, not PHP.