【发布时间】:2019-06-25 23:38:47
【问题描述】:
我正在为工作表创建一个谷歌插件。我正在处理的侧边栏旨在作为一种帮助票提交,但在我开发这部分内容之前,我没有在表单中获得提交按钮来调用我想要构建的 javascript 函数。
我已经从 html 按钮调用中删除了所有表单数据以激活 Logger.log。没有骰子。 我创建了一个完全独立(并且非常简单)的按钮来调用不同的函数来调用 Logger.log。这也没有奏效。 我已经仔细检查了表单数据、发送调用和函数。 我确保函数的名称 (sendMsg) 是唯一的。 我认为问题可能不在我的代码中,而是以其他方式连接了 html 和 javascript (.gs)。
这里是html表单:
<div class="block form-group">
<form>
<label for="reason">Purpose of Contact</label>
<select id="reason">
<option selected>Help Request</option>
<option>Feature Request</option>
<option>Error Report</option>
<option>Other</option>
</select>
<label for="email">Email</label>
<input type="text" id="email" style="width: 200px;">
<label for="phone">Phone</label>
<input type="text" id="phone" style="width: 120px;" value = "optional">
<br>
<label for="translated-text">
<b>Message</b></label>
<textarea id="userMsg" rows="15" cols="35">
</textarea>
<br>
<input id="app" name="appSrc" type="hidden" value="COE">
<input type="button" class="action" name="helpRequest" value="SEND" onClick="google.script.run.sendMsg(
document.getElementById('reason').value,
document.getElementById('email').value,
document.getElementById('phone').value,
document.getElementById('userMsg').value,
document.getElementById('appSrc').value
)" />
</form>
</div>
这里是调用的函数:
function sendMsg(appSrc,reason,email,phone,userMsg) {
appV = appSrc;
reasonV = reason;
emailV = email;
phoneV = phone;
userMsgV = userMsg;
Logger.log('cheese');
}
现在表单应该只生成一个 Logger.log 消息。此时没有任何反应。
【问题讨论】:
-
谢谢。我有一种感觉,这很简单。我现在收到了 Logger.log 反馈,这将使我能够继续前进。
标签: javascript html forms google-apps-script google-sheets