我正在使用ui.prompt()来为我的应用程序脚本的其余部分提供用户输入。但是,如果用户输入响应的空间更大,那么如果他们必须输入相当多的内容(4-5句话),则整个文本是可见的,而不是鼠标移动到输入的开头/结尾。
我不确定是否有一个函数允许我为输入部分设置一个自定义大小(高度和宽度,或者变量,比如文本窗口的“拖动角”)。
var ui = SpreadsheetApp.getUi();
var bodyresponse = ui.prompt(
"The default email template is: " +
"\n\nIf you have any questions regarding your order, please email us directly by replying." +
"\n\nIf you would like to update your contact information, billing/shipping address, " +
"or have an adjustment to make on the Purchase Order attached to this email, " +
"please reach out to us within 7 days of receiving this Purchase Order." +
"\n\nThank you from Area Code 407!" +
"\n\nWould you like to include an accompanying note? If so, include it below: \n\n\n\n ",
ui.ButtonSet.YES_NO);发布于 2019-02-15 17:54:21
不幸的是,提示功能将不允许您这样做。但是,您可以通过制作一个对话框来实现您想要的结果。然后,使用客户端到服务器的通信,您可以将信息传递回服务器端脚本。
这不是一个完美的例子,而是需要做什么的一般想法。
Code.gs
var htmlOutput = HtmlService
.createHtmlFromFile('Dialog')
.setWidth(250)
.setHeight(300);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'My Title');
function dialogData(userNote){
//Do something with userNote...
}Dialog.html
<body>
Hello, world!
<p> The default email template is: </p>
<p>If you have any questions regarding your order, please email us directly by replying. If you would like to update your contact information, billing/shipping address, or have an adjustment to make on the Purchase Order attached to this email, please
reach out to us within 7 days of receiving this Purchase Order.</p>
<p>Thank you from Area Code 407! </p>
<p>Would you like to include an accompanying note? If so, include it below: </p>
<textarea id="userNote" rows="4" cols="80"></textarea>
<input type="button" value="Submit" onclick="returnData()" />
<script>
function returnData() {
var note = document.getElementById("userNote").value
console.log(note);
google.script.run.onSuccessHandler(closeMe).dialogData(); //This calls a script in your main Code.gs serverside.
}
function closeMe() {
google.script.host.close();
}
</script>
</body>
https://stackoverflow.com/questions/54713254
复制相似问题