Javascript 将html单选按钮值传递给Google应用程序脚本
在上一个关于在GS和html之间传递值的问题之后,我取得了一些进展。我能够将html侧栏中的文本输入值存储到Google propertiesservice中,然后在再次打开时将其传递回侧栏。然而,这似乎对我的单选按钮不起作用。谁能帮我解决这个问题 下面的代码处理来自侧栏的输入Javascript 将html单选按钮值传递给Google应用程序脚本,javascript,html,google-apps-script,Javascript,Html,Google Apps Script,在上一个关于在GS和html之间传递值的问题之后,我取得了一些进展。我能够将html侧栏中的文本输入值存储到Google propertiesservice中,然后在再次打开时将其传递回侧栏。然而,这似乎对我的单选按钮不起作用。谁能帮我解决这个问题 下面的代码处理来自侧栏的输入 function processForm(form) { radio = form.radioEmail; userProperties.setProperty('selectedRadio', radio);
function processForm(form) {
radio = form.radioEmail;
userProperties.setProperty('selectedRadio', radio);
time = form.time;
userProperties.setProperty('selectedTime', time);
};
以下代码将存储的输入输出放入html侧栏:
function openTasksSettings() {
var htmlTemplate = HtmlService.createTemplateFromFile('tasksSettings');
htmlTemplate.timehtml = time;
htmlTemplate.radiohtml = radio;
var html = htmlTemplate.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setTitle('Settings')
.setWidth(300)
SpreadsheetApp.getUi()
.showSidebar(html);
return html
};
最后是html代码(减去不相关的部分)
发送电子邮件提醒:
在google.script.run.processForm(document.forms[0])行中,可能存在重复的is
,文档。表单[0]
作为未定义发送,因为您的错误是在未定义时调用无线电子邮件
<div>
<form>
<strong>Send email reminders:</strong><br>
<input type="radio" name="radioEmail" id="radio1" value="<?!= radiohtml ?>" Yes>
<label for="radio1">Yes</label>
<input type="radio" name="radioEmail" id="radio2" value="<?!= radiohtml ?>" No>
<label for="radio2">No</label><br><br>
<strong>Send reminders:</strong><br>
<input type="text" name="time" id="time" style="width: 40px;" value="<?!= timehtml ?>">
<label for="select">days before due date</label>
<br><br><input type="button" class="action" onClick="writeFormData(); alert('submitted')" value="Submit"/>
</form>
</div>
<script type="text/javascript">
function writeFormData() {
google.script.run.processForm(document.forms[0]);
}
</script>