简体   繁体   English

如何在脚本运行之前将Google表单中的确认页面延迟?

[英]How to delay confirmation page in Google Forms until script has run?

I'm working in modifying a google form to process information from my team. 我正在修改Google表单以处理来自团队的信息。 I want them to provide information on New Projects and Existing Projects. 我希望他们提供有关新项目和现有项目的信息。 If Existing Projects is selected, it displays a URL to take the user to another form. 如果选择了“现有项目”,它将显示一个URL,以将用户带到另一个表单。 I want the confirmation page to only display the link to the next form if the user has selected “Existing Projects”. 我希望确认页面仅在用户选择了“现有项目”时才显示指向下一个表单的链接。

I know previous answers on this site and from Google Help state that you cannot dynamically change the confirmation notice. 我们知道该站点上的先前答案以及Google帮助中的答案都表明您无法动态更改确认通知。 However, I have written a function which takes the user response and changes the confirmation response using GAS .setConfirmationMessage(). 但是,我编写了一个函数,该函数接受用户响应并使用GAS .setConfirmationMessage()更改确认响应。 However, this only takes effect using the onSubmit trigger, and the confirmation page is loading too quickly right now to change the information from the current response. 但是,这仅在使用onSubmit触发器时生效,并且确认页面现在加载速度太快,无法更改当前响应中的信息。

    function pageDisplay(){
       var form=FormApp.getActiveForm();
       var formResponses=form.getResponses();
       var lastFormResponse=formResponses.pop();
       var itemResponses=lastFormResponse.getItemResponses();
       var itemResponse=[]; //initialize array

     for (var i=0; i<itemResponses.length; i++){
         itemResponse[i]=itemResponses[i].getResponse();
        }

     switch (itemResponse[0].toString()){
         case "Existing Project":
            form.setConfirmationMessage("Thank you now please visit URL");
            form.setConfirmationMessage(url);
          break;

        case "New Project":
           form.setConfirmationMessage("Thank you for your new information").setShowLinkToRespondAgain(true);
          break;

}} }}

Question : How can I slow down the loading of the confirmation page until after the script has run? 问题 :在脚本运行之后,如何降低确认页面的加载速度? Is this possible? 这可能吗?

I am getting used to GAS but have no experience in HTML or webpage JS so please be detailed if it involves those. 我已经习惯了GAS,但没有HTML或网页JS的经验,因此如果涉及到这些内容,请进行详细说明。 Thank you for your help! 谢谢您的帮助!

Google Forms doesn't include a built-in feature to change published form behaviors like delaying the displaying of the confirmation page. Google表单没有内置功能来更改已发布的表单行为,例如延迟确认页面的显示。

One alternative is to get control of the POST request to the Google Form app by using UrlFetchApp but this could unnecessarily over-complicate your a solution to be deployed as "production". 一种替代方法是使用UrlFetchApp来控制对Google Form应用程序的POST请求,但这可能不必要地使您要部署为“生产”的解决方案过于复杂。 If you still want to take this way, you should the use HTMLService to display a html form with a custom form submit action that will emulate the form action of the published Google Form. 如果仍要采用这种方式,则应使用HTMLService来显示带有自定义表单提交操作的html表单,该操作将模仿已发布的Google表单的表单操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM