2012-10-16 115 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