【问题标题】:How to customize google forms that have 'other-option-response' option and textbox (and get responses to google sheet)如何自定义具有“其他选项响应”选项和文本框的谷歌表单(并获得对谷歌表的响应)
【发布时间】:2017-08-12 19:09:58
【问题描述】:

因此,有许多网站解释了如何为您的网站自定义您自己的 google 表单(链接到 google 表格),例如 codepen 和 this blog

但是,到目前为止,我没有找到任何解释如何处理具有“其他选项响应”选项的 Google 表单,例如:my example with other gender

我已经成功地解决了如何处理表单中不包含此内容的谷歌表单(因为他们的回复显示在相应的谷歌表格上)。但是,当谈到此功能时,我感到很困惑,因为我可以提交表单,但谷歌表格中没有显示任何回复。

这是可能给我带来麻烦的代码的 sn-p。

<label>Student's Gender:</label><br>
    <input name="entry.1921054985" type="radio" value="Male" required style="color: black;" onclick="document.getElementById('genderother').disabled=true;
                                        document.getElementById('genderother').value=''" />Male<br>
    <input name="entry.1921054985" type="radio" value="Female" style="color: black;" onclick="document.getElementById('genderother').disabled=true;
                                        document.getElementById('genderother').value=''" />Female<br>
    <input name="entry.1921054985" type="radio" value="__other_option__" style="color: black;" onclick="document.getElementById('genderother').disabled=false;
                                        document.getElementById('genderother').focus();" />Other:
    <input name="entry.1921054985.other_option_response" type="text" placeholder="Enter if applicable" style="color:black;" id="genderother" disabled/>

我想知道我的方式是否是处理“其他”响应的正确方式。

这是我关于stackoverflow的第一个问题,所以如果我做错了什么,或者没有做某事,请告诉我。

【问题讨论】:

    标签: html google-sheets customization google-forms


    【解决方案1】:

    您是在创建 Google 表单,还是在制作 HTML 表单的已发布 Web 应用?

    对于您引用的博客正在处理的 Google 表单,您将拥有如下内容:

    var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
     var item = form.addMultipleChoiceItem();
     item.setTitle('Do you prefer cats or dogs?')
         .setChoices([
             item.createChoice('Male'),
             item.createChoice('Female')
             item.createChoice('Prefer not to say')
          ])
         .showOtherOption(true);
    

    修改自Class MultipleChoiceItem documentation page

    但是,您似乎没有使用表单服务,而是直接生成 HTML。如果这是您的意图,请参阅HTML Forms: Radio buttons with text fields 上的此线程

    【讨论】:

    • 我使用的是纯 HTML。我已经知道如何制作 HTML 表单了。表格出现。但是,响应不会记录在 Google 表格中。
    • 好的,在帖子中使用“google forms”并添加其他建议的google-forms标签。我删除了标签并添加了 google-apps-script。
    • 另外,您是否查看了我在回复的最后部分中链接的主题?由于 Google Apps 脚本基于 javascript,因此该线程应适用于您的需求。
    • 我已经看过了。我想你误解了我的问题。我没有使用 Google Apps 脚本(尽管这样会更好吗?)。单选按钮线程未解决如何使用 Google 表单。所以基本上,我创建了一个谷歌表单。该 Google 表单链接到 Google SpreadSheet。我不想直接使用 Google 表单,因为我不希望用户离开我的网站。因此,我在我的网站上创建了一个表单,其操作属性对应于电子表格,输入标签的名称与谷歌表单中的名称相对应。
    • 因此电子表格将记录用户在我的网站上输入表单的响应。这以前对我有用。只是现在,我第一次处理“其他”响应,突然之间电子表格不再记录数据。
    猜你喜欢
    • 2015-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-03
    • 2021-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多