2010-07-26 64 views
2

我想在這兩個JavaScript函數,但低於第二個功能,我無法從全局變量中獲得的價值份額值的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函數但低於第二個函數我無法從全局變量中獲取值

回答

8

您定義了變量masterTable,但是正在以小寫形式訪問它mastertable