javascript 如何在 Google 表单中添加动态字段?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12178175/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 15:30:11  来源:igfitidea点击:

How can I add dynamic field in Google Form?

javascriptjquerygoogle-apps-scriptgoogle-form

提问by Viral Shah

Is there any feature Add New Field using jQueryor Add fields using Javascriptin Google forms?

在 Google 表单中是否有使用 jQuery 添加新字段使用 Javascript 添加字段的功能

I'm creating a questionnaire application using google apps script and questions and answers will be set from my admin panel (admin decide how many questions will be there). It would be perfect if there was a (+) next to the form to automatically load another text box underneath the form.

我正在使用谷歌应用程序脚本创建一个问卷应用程序,问题和答案将从我的管理面板设置(管理员决定有多少问题)。如果表单旁边有一个 (+) 可以自动加载表单下方的另一个文本框,那就太完美了。

采纳答案by Viral Shah

I founded the perfect reason for this why it's unable to add dynamic fields with the Google Forms because Google Forms applications are totally bonded with the spread sheets

我找到了为什么它无法使用 Google 表单添加动态字段的完美原因,因为 Google 表单应用程序与电子表格完全绑定

All the Forms having individual spreadsheets there.

所有表格都有单独的电子表格。

So, it's impossible to generate dynamic fields in the Google forms because of strongly associated with the spreadsheet so.

因此,由于与电子表格密切相关,因此不可能在 Google 表单中生成动态字段。

This we can say the static relation between Google Forms and Spreadsheets.

这可以说是 Google Forms 和 Spreadsheets 之间的静态关系。

回答by Tim

I think you want to build a new page that can submit to a Google spreadsheet using Using jQuery with JSON and Google Spreadsheets Data API

我认为您想构建一个新页面,该页面可以使用 Using jQuery with JSON 和 Google Spreadsheets Data API 提交到 Google 电子表格

回答by Rubén

Short answer

简答

Yes you can create/edit a form programmatically by using the Forms Service Class Form

是的,您可以使用 Forms Service Class Form以编程方式创建/编辑表单

Note: At this time it's not possible to make changes to form / questions based on user input like making cascading dropdowns.

注意:目前无法根据用户输入更改表单/问题,例如制作级联下拉菜单。

Extended answer

扩展答案

The following are the specific methods to add each question type to a Google form.

以下是将每种问题类型添加到 Google 表单的具体方法。

Method                      Return type             Brief description
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
addCheckboxItem()           CheckboxItem            Appends a new question item that allows the respondent to select one or more checkboxes, as well as an optional "other" field.
addDateItem()               DateItem                Appends a new question item that allows the respondent to indicate a date.
addDateTimeItem()           DateTimeItem            Appends a new question item that allows the respondent to indicate a date and time.
addDurationItem()           DurationItem            Appends a new question item that allows the respondent to indicate a length of time.
addGridItem()               GridItem                Appends a new question item, presented as a grid of columns and rows, that allows the respondent to select one choice per row from a sequence of radio buttons.
addListItem()               ListItem                Appends a new question item that allows the respondent to select one choice from a drop-down list.
addMultipleChoiceItem()     MultipleChoiceItem      Appends a new question item that allows the respondent to select one choice from a list of radio buttons or an optional "other" field.
addParagraphTextItem()      ParagraphTextItem       Appends a new question item that allows the respondent to enter a block of text.
addScaleItem()              ScaleItem               Appends a new question item that allows the respondent to choose one option from a numbered sequence of radio buttons.
addTextItem()               TextItem                Appends a new question item that allows the respondent to enter a single line of text.
addTimeItem()               TimeItem                Appends a new question item that allows the respondent to indicate a time of day.

See also

也可以看看