【问题标题】:Couldn't find the name attribute in google form after inspecting the input field检查输入字段后在谷歌表单中找不到名称属性
【发布时间】:2020-12-04 19:56:30
【问题描述】:

https://docs.google.com/forms/d/e/1FAIpQLSe4-5jfzznYBB1UByawdNucFRls2Nt17MgT5K1w_ikKUrByVQ/viewform。这是我的谷歌表格的链接。当我检查输入元素时,我找不到名称属性。我需要名称属性,以便我可以将我的 HTML 表单数据存储到谷歌电子表格。该属性必须包含类似“entry.***”的值。当我检查输入元素时,显示以下内容,没有任何名称属性:

<input type="text" class="quantumWizTextinputPaperinputInput exportInput" jsname="YPqjbf" autocomplete="off" tabindex="0" aria-labelledby="i1" aria-describedby="i2 i3" dir="auto" data-initial-dir="auto" data-initial-value="">

从哪里获取名称属性?

【问题讨论】:

    标签: javascript html forms google-sheets google-forms


    【解决方案1】:

    Google 表单是动态生成的

    您将无法在此处自定义 HTML 元素的属性,因为它是动态生成的。如果您想创建一个表单并对其行为方式有更多控制权,并且您希望保持与 Google 服务的集成,那么最好的选择是使用网络应用程序。

    Web Apps

    这将允许您在编写自己的 HTML 时自定义元素的属性。例如,最简单的网络应用之一如下所示:

    function doGet(){
    
     var HTMLString = "<style> h1,p {font-family: 'Helvitica', 'Arial'}</style>"
     + "<h1>Hello World!</h1>"
     + "<p>Welcome to the Web App";
    
     HTMLOutput = HtmlService.createHtmlOutput(HTMLString);
     return HTMLOutput
    }
    

    更多信息链接如下。你可以:

    • 创建您的 Apps 脚本项目
    • 编写上述函数的一个版本,并为您的链接制作一个 HTML 表单。然后,您可以将 onSubmit 事件分配给表单,该事件将触发 Apps 脚本中的函数以使用其信息更新您的电子表格。您可以使用如下语法从客户端 HTML 调用 Apps 脚本函数:
    google.script.run.testFunc()
    

    关于here的更多信息。

    参考文献

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-19
      • 2017-10-02
      • 1970-01-01
      • 2022-11-02
      • 2011-04-25
      • 2019-10-18
      • 1970-01-01
      • 2014-04-04
      相关资源
      最近更新 更多