我想在两个javascript函数之间共享值,但是在下面的第二个函数中,我无法从全局变量中获取值

// Following two are global variables
    var grid;
    var masterTable;

    function GridCreated(sender, args)
    {
        grid = sender; // setting values
        masterTable = sender.get_masterTableView(); // setting values - Here masterTable has values in it
        masterTable.selectAllItems(true);
    }



    function abc()
    {
        debugger;
        var collectionofordernumber = 0;


               var selectedrows = mastertable.get_selecteditems(); // HERE I UNABLE TO GET THE VALUES FROM MASTERTABLE

        for (var i = 0; i < selectedrows.length; i++)
               {
                   var row = selectedrows[i];
                   var cell = mastertable.getcellbycolumnuniquename(row, "ordernumber")
           collectionofordernumber = collectionofordernumber + "-" + cell.innerhtml;
                }

        document.getelementbyid("hdf1").value = collectionofordernumber;
        alert('I m here');
    }

我想在两个javascript函数之间共享值,但是在下面的第二个函数中,我无法从全局变量中获取值

最佳答案

您定义了masterTable变量,但是正在使用小写的mastertable访问它?

10-06 01:07