2012-10-16 30 views
3

我创建了一个Google文档表单并制作了Google脚本小工具,将数据发布到表单的电子表格后端,然后返回自定义html5确认页面。HtmlService doPost With Google Docs表单

我在我的脚本代码中使用了HTMLService,doPost(e)doGet(e),并且还使用我的小工具(表单和确认html文件)创建了2个html文件。

它将数据写入正确电子表格的小工具;然而,它并没有返回我用我的小工具创建的正确的确认html文件。它返回的是谷歌文档表单的一部分的确认页面。下面是我的代码的doPost部分的一部分。有没有人有任何想法如何让它返回我创建的自定义确认HTML文件而不是Google文档?

function doPost(e) { 
    var template = HtmlService.createTemplateFromFile('confirm.html'); 
    template.entry_0 = e.entry_0; 
    template.entry_1 = e.entry_1; 
    template.entry_2 = e.entry_2; 
    template.entry_3 = e.entry_3; 
    template.screenshot = e.parameter.screenshot; 
return template.evaluate(); 
} 

form.html文件中的表单动作代码行如下。

<form action="<?= "https://docs.google.com/spreadsheet/formResponse?formkey=$mungedformkey" ?>" method="post"> 

回答

2

当您张贴到一个网址,该网址是什么决定下一步会发生什么 - 你的doPost从未得到调用。作为替代方法,尝试发布到脚本(使用doPost或更好使用google.script.run发布语法)并使用UrlFetchApp将数据传递给表单;那么你将得到控制表单响应。

+0

谢谢,我会试着看看。 – Kinnara