View The Retrieved Data from webSQL Database in list
I want to view the database data in <li> format and actually the data are names of picture I want to view. Here's the javascript database code
- var createStatement = "CREATE TABLE IF NOT EXISTS batikPattern (id INTEGER PRIMARY KEY AUTOINCREMENT, originalPattern TEXT, outlinePattern TEXT)";
-
- var selectAllStatement = "SELECT * FROM batikPattern";
-
- var dropStatement = "DROP TABLE batikPattern";
-
- var db = openDatabase("BatiQu", "1.0", "Address Book", 200000); // Open SQLite Database
-
- var dataset;
-
- var DataType;
-
- function initDatabase() // Function Call When Page is ready.
-
- {
-
- try {
-
- if (!window.openDatabase) // Check browser is supported SQLite or not.
-
- {
-
- alert('Databases are not supported in this browser.');
-
- }
-
- else {
-
- createTable(); // If supported then call Function for create table in SQLite
-
- }
-
- }
-
- catch (e) {
-
- if (e == 2) {
-
- // Version number mismatch.
-
- console.log("Invalid database version.");
-
- } else {
-
- console.log("Unknown error " + e + ".");
-
- }
-
- return;
-
- }
-
- }
-
- function createTable() // Function for Create Table in SQLite.
-
- {
- db.transaction(populateDB, errorCB, successCB);
- // db.transaction(function (tx) { tx.executeSql(createStatement, [], showRecords, onError); });
-
- }
-
- function populateDB(tx) {
- tx.executeSql('DROP TABLE IF EXISTS batikPattern');
- tx.executeSql(createStatement, []);
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik1", "outlineBatik1")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik2", "outlineBatik2")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik3", "outlineBatik3")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik4", "outlineBatik4")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik5", "outlineBatik5")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik6", "outlineBatik6")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik7", "outlineBatik7")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik8", "outlineBatik8")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik9", "outlineBatik9")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik10", "outlineBatik10")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik11", "outlineBatik11")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik12", "outlineBatik12")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik13", "outlineBatik13")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik14", "outlineBatik14")');
- tx.executeSql('INSERT INTO batikPattern(originalPattern,outlinePattern) VALUES ("batik15", "outlineBatik15")');
-
- }
-
- //function will be called when an error occurred
- function errorCB(err) {
- // alert("Error processing SQL: "+err.code);
- }
-
- //function will be called when process succeed
- function successCB() {
-
- // alert("success!");
- db.transaction(queryDB,errorCB);
- }
-
-
-
- function queryDB(tx){
- tx.executeSql('SELECT * FROM batikPattern',[],querySuccess,errorCB);
- }
-
- function querySuccess(tx,result){
- $('#batikPic').empty();
- $.each(result.rows,function(index){
- var row = result.rows.item(index);
- $('#batikPic').append('<li><img src="images/Real-Pattern/'+row['originalPattern']+'.jpg"/></li>');
- });
- $('#batikPic').listview();
-
- }
-
-
-
-
- function onError(tx, error) // Function for Hendeling Error...
-
- {
-
- alert(error.message);
-
- }
-
-
- $(document).ready(function () // Call function when page is ready for load..
-
- {
-
- initDatabase();
-
- });
-
The Bold text is where I sense the problem comes from
and the HTML section for that is
- <div class="frame" id="basic">
- <ul class="clearfix" id="batikPic">
-
-
- </ul>
- </div>
Anyone knows what seems to be the problem here? When I inspect the element using google chrome the error says something like "Index must be in numbers". Thanks in advance