2014-03-26 56 views
0

我試圖插入註冊表單值到sqlite數據庫使用jQuery,不知道我要去哪裏錯了,有誰能幫我解決這個問題嗎?jQuery編程在sqlite數據庫中存儲值

var db=openDatabase("foo4","1.0","my simple database","200000"); 
      db.transaction(function (tx) 
       { 
        if ($("#gender").attr("checked", "true")) 
        { 
         var $g="male"; 
        } 
        else 
        var $g="female"; 
        tx.executeSql('CREATE TABLE IF NOT EXISTS foo4 (rno INTEGER, name TEXT, email TEXT, phone INTEGER, age INTEGER, address TEXT, password TEXT, gender TEXT)'); 
        tx.executeSql('INSERT INTO foo4 VALUES('+$("#rno").val()+',"'+ 
         $("#name").val()+'","'+$(#"email").val()+'",'+$(#"pno").val()+','+ 
         $(#"age").val()+',"'+$(#"address").val()+'","'+$(#"pwd").val()+'","'+$("#g").val()+'")'); 
        alert("success"); 
        window.open("home.html","_self");   
       }); 
     } 
else 
    window.alert(error); 

蔭收到錯誤作爲

tx.executeSql('INSERT INTO foo4 VALUES(' + $("#rno").val() + ',"' + $("#name").val() + '","' + $(#"email").val() + '",' + $(#"pno").val() + ',' + $(#"age").val() + ',"' + $(#"address").val() + '","' + $(#"pwd").val() + '","' + $("#g").val() + '")'); 

Uncaught SyntaxError: Unexpected string 
+0

你有一些'$(# 「PWD」)'應該是'$(「#PWD 「)' –

回答

0

試試這個:

tx.executeSql('INSERT INTO foo4 VALUES('+$("#rno").val()+',"'+ 
        $("#name").val()+'","'+$("#email").val()+'",'+$("#pno").val()+','+ 
        $("#age").val()+',"'+$("#address").val()+'","'+$("#pwd").val()+'","'+$("#g").val()+'")') 
+0

是的,它的工作。謝謝 :) –

相關問題