gpt4 book ai didi

Javascript - 访问全局变量时出现问题

转载 作者:行者123 更新时间:2023-12-03 18:19:43 25 4
gpt4 key购买 nike

我想在两个 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 访问它?

关于Javascript - 访问全局变量时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3333906/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com