谷歌应用脚本TextBox值不会传递给e.parameter.TextBoxName [英] google apps script TextBox value not passed to e.parameter.TextBoxName
问题描述
在下面的代码中,我定义了一个带有名称和ID的TextBox。按钮处理程序工作正常,但我无法获得在TextBox中输入的值。 msgBox出现,但 e.parameter.matchValue
显示为 undefined
。
在应用程序的其他部分,我具有相同的逻辑,但具有ListBox并且工作正常。
>我做错了什么? function chooseColumnValueToMatch(){
var app = UiApp.createApplication ().setHeight(150).setWidth(250);
var ss = SpreadsheetApp.getActiveSpreadsheet();
var columnName = ScriptProperties.getProperty(columnNameToMatch);
var h1Line = app.createHTML(< h2>要匹配的值+ columnName +:< / h2>);
var textPara = app.createHTML(< p>键入< b>+ columnName +< / b>列必须匹配的值确切地发送消息。< / p>) ;
var selectionHandler = app.createServerHandler('chooseColumnValueToMatchSelectionHandler');
var valueInputBox = app.createTextBox()
.setTitle(Match value for+ columnName)
.setName(matchValue)
.setId(matchValue);
var submitBtn = app.createButton(Submit,selectionHandler);
app.add(h1Line)
.add(textPara)
.add(valueInputBox)
.add(submitBtn);
ss.show(app);
函数chooseColumnValueToMatchSelectionHandler(e){
var app = UiApp.getActiveApplication();
var columnName = ScriptProperties.getProperty(columnNameToMatch);
var ss = SpreadsheetApp.getActiveSpreadsheet();
var msg = e.parameter.matchValue;
Browser.msgBox(Value to match+ columnName +column is:,msg,Browser.Buttons.OK);
返回应用;
好像你忘了添加一个callbackElement到你的处理程序中
你可以这样试试:
selectionHandler.addCallbackElement(valueInputBox)
紧跟在submitBtn定义之后
On the code below I am defining a TextBox with name and id. The button handler works fine but I am not been able to get the value entered on the TextBox. The msgBox shows up but the e.parameter.matchValue
shows as undefined
.
On other part of the app I have the same logic but with a ListBox and it works fine.
What am I doing wrong?
function chooseColumnValueToMatch() {
var app = UiApp.createApplication().setHeight(150).setWidth(250);
var ss = SpreadsheetApp.getActiveSpreadsheet();
var columnName = ScriptProperties.getProperty("columnNameToMatch");
var h1Line = app.createHTML("<h2>Value to match "+columnName+":</h2>");
var textPara = app.createHTML("<p>Type the VALUE that the <b>"+columnName+"</b> column must match EXACTLY to send the message.</p>");
var selectionHandler = app.createServerHandler('chooseColumnValueToMatchSelectionHandler');
var valueInputBox = app.createTextBox()
.setTitle("Match value for "+columnName)
.setName("matchValue")
.setId("matchValue");
var submitBtn = app.createButton("Submit", selectionHandler);
app.add(h1Line)
.add(textPara)
.add(valueInputBox)
.add(submitBtn);
ss.show(app);
}
function chooseColumnValueToMatchSelectionHandler(e){
var app = UiApp.getActiveApplication();
var columnName = ScriptProperties.getProperty("columnNameToMatch");
var ss = SpreadsheetApp.getActiveSpreadsheet();
var msg = e.parameter.matchValue;
Browser.msgBox("Value to match "+columnName+" column is:", msg, Browser.Buttons.OK);
return app;
}
It seems that you forgot to add a callbackElement to your handler
you could try like this :
selectionHandler.addCallbackElement(valueInputBox)
right after the submitBtn definition
这篇关于谷歌应用脚本TextBox值不会传递给e.parameter.TextBoxName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!