问题描述
我了解已被标记为固定,但我似乎无法从我的htmlservice表单传递给我的谷歌应用程序脚本的任何参数。以下是我所尝试的:
< my html file>
< form id =myForm>
< input name =aFieldid =aField>
< input type =buttonid =submitvalue =submitonclick =sendData()>
< / form>
< script>
函数sendData(){
google.script.run.processForm(document.getElementById(myForm));
}
< / script>
< / my html文件>
< google apps脚本>
函数processForm(value){
var range = SpreadsheetApp.openById(1234)。getRangeByName(testRnage);
range.setValue(value.aField);
}
< / google apps脚本>使用
>< input type =buttonid =submitvalue =submitonclick =google.script.run.processForm(this.parentNode)> 也不起作用。 / p>
这两种方法都会导致以下浏览器错误:Uncaught ScriptError:TypeError:Can not call methodsetValueof null。
任何帮助表示赞赏。感谢。
我一直在成功地做到这一点:
var invoice = new Object();
invoice.customerCode = selectedCustomer.value;
invoice.discount = document.getElementById('discount')。value;
invoice.items = blah,blah,blah。 。 。
var jsonInvoice = JSON.stringify(invoice);
google.script.run.recordInvoice(jsonInvoice);
...在服务器上...
函数recordInvoice(jsonInvoice){
var theInvoice = eval((+ jsonInvoice +));
var cust = theInvoice.customerCode;
如果看起来不完整,请随时索取详细资料。
I understand issue 1660 has been marked as fixed but I cannot seem to get any parameters passed from my htmlservice form to my google apps script. Here's what I have tried:
<my html file>
<form id="myForm">
<input name="aField" id="aField">
<input type="button" id="submit" value="submit" onclick = "sendData()">
</form>
<script>
function sendData() {
google.script.run.processForm(document.getElementById("myForm"));
}
</script>
</my html file>
<google apps script>
function processForm(value) {
var range = SpreadsheetApp.openById("1234").getRangeByName("testRnage");
range.setValue(value.aField);
}
</google apps script>
Using
<input type="button" id="submit" value="submit" onclick = "google.script.run.processForm(this.parentNode)">
does not work either.
Both methods result in the following browser error: "Uncaught ScriptError: TypeError: Cannot call method "setValue" of null."
Any help is appreciated. Thanks.
I have been doing this successfully :
var invoice = new Object();
invoice.customerCode = selectedCustomer.value;
invoice.discount = document.getElementById('discount').value;
invoice.items = blah, blah, blah . . .
var jsonInvoice = JSON.stringify(invoice);
google.script.run.recordInvoice(jsonInvoice);
... with this on the server ...
function recordInvoice(jsonInvoice) {
var theInvoice = eval("(" + jsonInvoice + ")");
var cust = theInvoice.customerCode;
Feel free to ask for elaboration if that seems incomplete.
这篇关于" google.script.run.function"不从htmlservice传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!