谷歌表单脚本-从单选按钮获取值,目前未定义
Google Sheets script - get value from radio button, currently undefined
我有一个谷歌脚本在表中创建一个侧边栏。侧边栏是使用UiApp动态生成的,而不是HTML。用户单击其中一个单选按钮来进行选择(其中可能有超过200个,并且它们的值会定期更改,因为它们取自特定的工作表)。
我试图传递单选按钮的值,但它总是出现为未定义:
//get the values over
var MaxRow=250;
var LookIn=0;
var L1; var L2; var L3;
for(LookIn=1;LookIn<MaxRow;LookIn++)
{
L1=sheet.getRange("AB" + LookIn);
L2=sheet.getRange("AC" + LookIn);
L3=sheet.getRange("AD" + LookIn);
if(L1.getValues()!=""){UIInstance.add(UIInstance.createLabel("_")); UIInstance.add(UIInstance.createHTML("<b>" + L1.getValues() + "</b>"));}
if(L2.getValues()!=""){UIInstance.add(UIInstance.createHTML("<b> > > " + L2.getValues() + "</b>"));}
if(L3.getValues()!="")
{
var RadioHandler=UIInstance.createServerChangeHandler('radioButtonsChange');
UIInstance.add(UIInstance.createRadioButton("MyButton").setId(L3.getValues).setText(L3.getValues()).addClickHandler(RadioHandler));
UIInstance.add(UIInstance.createLabel(""));
}
}
//add the sidebar
SpreadsheetApp.getUi()
.showSidebar(UIInstance);
}
function radioButtonsChange(e)
{
SpreadsheetApp.getUi().alert(e.parameter.source);
}
由于我们有这么多单选按钮,我基本上使用L3.getValues()来设置它们的属性,然后使用处理程序来调用它。目前,它确实会调用处理程序,该处理程序会传递给radioButtonsChange,但它总是显示"undefined"。
好了,我不太清楚我做了什么不同的事情,但是现在它可以工作了。
第一个东西:
var RadioHandler=UIInstance.createServerChangeHandler('radioButtonsChange');
UIInstance.add(UIInstance.createRadioButton("MyButton").setId(L3.getValues()).setText(L3.getValues()).addClickHandler(RadioHandler));
UIInstance.add(UIInstance.createLabel(""));
和最后一位:
function radioButtonsChange(e)
{
SpreadsheetApp.getUi().alert(e.parameter.source);
}
不知道,想想看
相关文章:
- 为什么“;未定义的“;在JavaScript中结束循环
- 要求未定义JS回调参数
- 如何检查管道中未定义的项目
- TypeError:无法读取属性'推'未定义的JavaScript
- $window.ga在AngularJS事件中未定义
- 未捕获的TypeError无法读取未定义的属性socialsharing
- 为什么grunt contrib connect的中间件选项的第三个参数是未定义的
- 无法获取属性'selectedIndex'的未定义引用或null引用
- 如何消除代码中的未定义和其他问题
- 未捕获的ReferenceError:$未定义
- this.router在AngularJS 2中未定义
- 未捕获的类型错误:无法读取属性'删除'的未定义
- 节点fs.stat名称未定义
- 尝试在PHP中回显输入文本时出现未定义的索引错误
- Jquery未定义函数正在停止其他操作
- AngularJS指令出错-无法读取属性'编译'的未定义
- 这.SOMETHING 总是返回未定义的 - extjs
- 无法获取属性'Id'使用Knockout.js的未定义或空引用API
- 在Javascript类中的另一个方法中使用方法-目前未定义
- 谷歌表单脚本-从单选按钮获取值,目前未定义