Javascript 无法调用方法';交易';空的

Javascript 无法调用方法';交易';空的,javascript,html,local-storage,web-sql,Javascript,Html,Local Storage,Web Sql,我得到以下错误 无法调用null的方法“transaction” 当尝试插入WEBSQL时(是的,我知道它已被弃用) 我有一个几乎完全相同的副本,这个脚本在另一个页面上运行良好,这个页面只是有一个不同的名称和单独的字段。代码如下 var html5rocks = {}; html5rocks.webdb = {}; html5rocks.webdb.db = null; html5rocks.webdb.open = function() { var dbSize = 5 * 102

我得到以下错误

无法调用null的方法“transaction”

当尝试插入WEBSQL时(是的,我知道它已被弃用)

我有一个几乎完全相同的副本,这个脚本在另一个页面上运行良好,这个页面只是有一个不同的名称和单独的字段。代码如下

var html5rocks = {};
html5rocks.webdb = {};

html5rocks.webdb.db = null;

html5rocks.webdb.open = function() {
    var dbSize = 5 * 1024 * 1024; // 5MB
    html5rocks.webdb.db = openDatabase('Customer', '1.0', 'customer manager', dbSize);
}

html5rocks.webdb.onError = function(tx, e) {
    alert('Something unexpected happened: ' + e.message );
    console.log('error');
}

html5rocks.webdb.onSuccess = function(tx, r) {


    var statusOutput = "Customer Form Saved!";
    var status = document.getElementById('status');
    $('.form-title-area').css('background-color','#26c622');
    $('.form-title-area').html('<h1>Customer Form Saved!</h1>');
    status.innerHTML = statusOutput;

    html5rocks.webdb.getAllTodoItems(loadTodoItems);
}

html5rocks.webdb.createTable = function() {
    html5rocks.webdb.db.transaction(function(tx) {
                                    tx.executeSql('CREATE TABLE IF NOT EXISTS ' + 
                                                  'customerform(ID INTEGER PRIMARY KEY ASC, companyname TEXT, tradingas TEXT, regadd1 TEXT, regadd2 TEXT, regaddcity TEXT, regaddstate TEXT, regaddcountry TEXT, regaddpostcode TEXT, cregno TEXT, vatregno TEXT, accountsname TEXT,  accountsphone TEXT, accountsemail TEXT, accountsfax TEXT, invadd1 TEXT, invadd2 TEXT, invaddcity TEXT, invaddstate TEXT, invaddcountry TEXT, invaddpostcode TEXT, creditlimit TEXT, firstorder TEXT, reqdeldate TEXT, deladd1 TEXT, deladd2 TEXT, deladdcity TEXT, deladdstate TEXT, deladdcountry TEXT, deladdpostcode TEXT, buyingname TEXT, buyingphone TEXT, buyingemail TEXT, buyingfax TEXT, ordersource TEXT, currency TEXT, deliveryterms TEXT, maxpallet TEXT, pallettype TEXT, wrap TEXT, invoiceterms TEXT, specialinstructions TEXT, bookingname TEXT, bookingphone TEXT, signed TEXT, signeddate TEXT, inputby TEXT, inputdate TEXT, added_on DATETIME)', []);
                                    });


}

html5rocks.webdb.addTodo = function(companynameText, tradingasText, regadd1Text, regadd2Text, regaddcityText, regaddstateText, regaddcountryText, regaddpostcodeText, cregnoText, vatregnoText, accountsnameText, accountsphoneText, accountsemailText, accountsfaxText, invadd1Text, invadd2Text, invaddcityText, invaddstateText, invaddcountryText, invaddpostcodeText, creditlimitText, firstorderText, reqdeldateText, deladd1Text, deladd2Text, deladdcityText, deladdstateText, deladdcountryText, deladdpostcodeText, buyingnameText, buyingphoneText, buyingemailText, buyingfaxText, ordersourceText, currencyText, deliverytermsText, maxpalletText, wrapText, invoicetermsText, specialinstructionsText, bookingnameText, bookingphoneText, signedText, signeddateText, inputbyText, inputdatetext) {


    html5rocks.webdb.db.transaction(function(tx){


                                    var addedOn = new Date();
                                    tx.executeSql('INSERT INTO customerform(companyname, tradingas, regadd1, regadd2, regaddcity, regaddstate, regaddcountry, regaddpostcode, cregno, vatregno, accountsname, accountsphone , accountsemail, accountsfax, invadd1, invadd2, invaddcity, invaddstate, invaddcountry, invaddpostcode, creditlimit, firstorder, reqdeldate, deladd1, deladd2, deladdcity, deladdstate, deladdcountry, deladdpostcode, buyingname, buyingphone ,buyingemail, buyingfax, ordersource, currency, deliveryterms, maxpallet, pallettype, wrap, invoiceterms, specialinstructions, bookingname, bookingphone, signed, signeddate, inputby, inputdate, added_on) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', 
                                                  [companynameText, tradingasText, regadd1Text, regadd2Text, regaddcityText, regaddstateText, regaddcountryText, regaddpostcodeText, cregnoText, vatregnoText, accountsnameText, accountsphoneText, accountsemailText, accountsfaxText, invadd1Text, invadd2Text, invaddcityText, invaddstateText, invaddcountryText, invaddpostcodeText, creditlimitText, firstorderText, reqdeldateText, deladd1Text, deladd2Text, deladdcityText, deladdstateText, deladdcountryText, deladdpostcodeText, buyingnameText, buyingphoneText, buyingemailText, buyingfaxText, ordersourceText, currencyText, deliverytermsText, maxpalletText, pallettypeText, wrapText, invoicetermsText, specialinstructionsText, bookingnameText, bookingphoneText, signedText, signeddateText, inputbyText, inputdateText, addedOn],
                                                  html5rocks.webdb.onSuccess,
                                                  html5rocks.webdb.onError);
                                    });


}




function init() {
    html5rocks.webdb.open();
    html5rocks.webdb.createTable();
    html5rocks.webdb.getAllTodoItems(loadTodoItems);

}

function initi() {

    html5rocks.webdb.getRecords();
}

function addTodo() {
console.log('trigger');
    var companyname = document.getElementById('companyname');
    var tradingas = document.getElementById('tradingas');
    var regadd1 = document.getElementById('regadd1');
    var regadd2 = document.getElementById('regadd2');
    var regaddcity = document.getElementById('regaddcity');
    var regaddstate = document.getElementById('regaddstate');
    var regaddcountry = document.getElementById('regaddcountry');
    var regaddpostcode = document.getElementById('regaddpostcode');
    var cregno = document.getElementById('cregno');
    var vatregno = document.getElementById('vatregno');
    //var vatregno = $('vatregno').val();
    var accountsname = document.getElementById('accountsname');
    var accountsphone = document.getElementById('accountsphone');
    var accountsemail = document.getElementById('accountsemail');
    var accountsfax = document.getElementById('accountsfax');
    var invadd1 = document.getElementById('invadd1');
    var invadd2 = document.getElementById('invadd2');
    var invaddcity = document.getElementById('invaddcity');
    var invaddstate = document.getElementById('invaddstate');
    var invaddcountry = document.getElementById('invaddcountry');
    var invaddpostcode = document.getElementById('invaddpostcode');
    var creditlimit = document.getElementById('creditlimit');
    var firstorder = document.getElementById('firstorder');
    var reqdeldate = $('.reqdeldate');
    var deladd1 = document.getElementById('deladd1');
    var deladd2 = document.getElementById('deladd2');
    var deladdcity = document.getElementById('deladdcity');
    var deladdstate = document.getElementById('deladdstate');
    var deladdcountry = document.getElementById('deladdcountry');
    var deladdpostcode = document.getElementById('deladdpostcode');
    var buyingname = document.getElementById('buyingname');
    var buyingphone = document.getElementById('buyingphone');
    var buyingemail = document.getElementById('buyingemail');
    var buyingfax = document.getElementById('buyingfax');
    var ordersource = document.getElementById('ordersource');
    var currency = document.getElementById('currency');
    var deliveryterms = document.getElementById('deliveryterms');
    var maxpallet = document.getElementById('maxpallet');
    var pallettype = document.getElementById('pallettype');
    var wrap = document.getElementById('wrap');
    var invoiceterms = document.getElementById('invoiceterms');
    var specialinstructions = document.getElementById('specialinstructions');
    var bookingname = document.getElementById('bookingname');
    var bookingphone = document.getElementById('bookingphone');
    var signed = document.getElementById('signed');
    var signeddate = $('.signeddate');
    var inputby = document.getElementById('inputby');

    var inputdate = $('.inputdate');

    console.log('triggers2');



    html5rocks.webdb.addTodo(companyname.value, tradingas.value, regadd1.value, regadd2.value, regaddcity.value, regaddstate.value, regaddcountry.value, regaddpostcode.value, cregno.value, vatregno.value, accountsname.value, accountsphone.value, accountsemail.value, accountsfax.value, invadd1.value, invadd2.value, invaddcity.value, invaddstate.value, invaddcountry.value, invaddpostcode.value, creditlimit.value, firstorder.value, reqdeldate.value, deladd1.value, deladd2.value, deladdcity.value, deladdstate.value, deladdcountry.value, deladdpostcode.value, buyingname.value, buyingphone.value, buyingemail.value, buyingfax.value, ordersource.value, currency.value, deliveryterms.value, maxpallet.value, pallettype.value, wrap.value, invoiceterms.value, specialinstructions.value, bookingname.value, bookingphone.value, signed.value, signeddate.value, inputby.value, inputdate.value);

    alert('Customer Form Saved');

}
var html5rocks={};
html5rocks.webdb={};
html5rocks.webdb.db=null;
html5rocks.webdb.open=函数(){
var dbSize=5*1024*1024;//5MB
html5rocks.webdb.db=openDatabase('Customer','1.0','Customer manager',dbSize);
}
html5rocks.webdb.onError=函数(tx,e){
警报(“发生意外事件:”+e.message);
console.log('error');
}
html5rocks.webdb.onSuccess=函数(tx,r){
var statusOutput=“客户表单已保存!”;
var status=document.getElementById('status');
$('.form title area').css('background-color','#26c622');
$('.form title area').html('Customer form Saved!');
status.innerHTML=状态输出;
html5rocks.webdb.getAllTodoItems(loadTodoItems);
}
html5rocks.webdb.createTable=函数(){
html5rocks.webdb.db.transaction(函数(tx){
tx.executeSql('CREATE TABLE IF NOT EXISTS'+
“客户绩效(ID INTEGER主键ASC、公司名称文本、交易名称文本、regadd1文本、regadd2文本、regaddcity文本、regaddstate文本、regaddcountry文本、regaddpostcode文本、cregno文本、vatregno文本、accountsname文本、accountsphone文本、AccountsMail文本、accountsfax文本、invadd1文本、invadd2文本、invaddcity文本、invaddstate文本、invaddcountry文本、InAddPostcode文本、creditlimit文本、firstorder文本、reqdeldate文本、deladd1文本、deladd2文本、deladdcity文本、deladdstate文本、deladdcountry文本、deladdpostcode文本、buyingname文本、buyingphone文本、buyingemail文本、buyingfax文本、ordersource文本、currency文本、DeladdTerms文本、MaxPalletType文本、wrap文本、,invoiceterms文本、specialinstructions文本、bookingname文本、bookingphone文本、签名文本、签名日期文本、inputby文本、inputdate文本、添加的_on DATETIME)、[];
});
}
html5rocks.webdb.addTodo=函数(公司名称文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本torderText、reqdeldateText、deladd1Text、deladd2Text、deladdcityText、deladdstateText、deladdcountryText、deladdpostcodeText、buyingnameText、buyingphoneText、buyingemailText、buyingfaxText、ordersourceText、currencyText、deliverytermsText、maxpalletText、wrapText、invoicetermsText、SpecialInstructionText、bookingnameText、bookingphoneText、signedText、signeddateText、inputbyText、inputdatetext){
html5rocks.webdb.db.transaction(函数(tx){
var addedOn=新日期();
tx.executeSql('插入到CustomPerform中(公司名称、Tradings、regadd1、regadd2、regaddcity、regaddstate、regaddcountry、regaddpostcode、cregno、vatregno、accountsname、accountsphone、AccountsMail、accountsfax、invadd1、invadd2、InvadCity、InvadState、InvadCountry、InvadPostcode、creditlimit、firstorder、reqdeldate、deladd1、deladd2、deladdcity、deladdstate、deladdcountry、deladdcountry、deladdpostcode,buyingname,buyingphone,buyingemail,buyingfax,ordersource,currency,deliveryterms,maxpallet,pallettype,wrap,invoiceterms,specialinstructions,bookingname,bookingphone,signed,signeddate,inputby,inputdate,added on)值(,
[公司名称文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本、交易文本torderText、reqdeldateText、deladd1Text、deladd2Text、deladdcityText、deladdstateText、deladdcountryText、deladdpostcodeText、buyingnameText、buyingphoneText、buyingemailText、buyingfaxText、ordersourceText、currencyText、deliverytermsText、maxpalletText、PalletText、wrapText、invoicetermsText、SpecialInstructionText、bookingnameText、bookingphoneText、signedText、signeddateText、inputbyText、inputdateText、addedOn],
html5rocks.webdb.onSuccess,
html5rocks.webdb.onError);
});
}
函数init(){
html5rocks.webdb.open();
html5rocks.webdb.createTable();
html5rocks.webdb.getAllTodoItems(loadTodoItems);
}
函数initi(){
html5rocks.webdb.getRecords();
}
函数addTodo(){
log('trigger');
var companyname=document.getElementById('companyname');
var tradingas=document.getElementById('tradingas');
var regadd1=document.getElementById('regadd1');
var regadd2=document.getElementById('regadd2');
var regaddcity=document.getElementById('regaddcity');
var regaddstate=document.getElementById('regaddstate');
var regaddcountry=document.getElementById('regaddcountry');
var regaddpostcode=document.getElementById('regaddpostcode');
var cregno=document.getElementById('cregno');
var vatregno=document.getElementById('vatregno');
//var vatregno=$('vatregno').val();
var accountsname=document.getElementById('accountsname');
var accountsphone=document.getElementById('accountsphone');
var accountsemail=document.getElementById('accountsemai