简体   繁体   English

来自 Google Forms Google Apps Script 的计算器

[英]Calculator from Google Forms Google Apps Script

I am newbee in google apps script.我是谷歌应用程序脚本中的新手。 So I learned how to code some functions in Sheets.所以我学会了如何在 Sheets 中编写一些函数。 But may Google Form use data from Sheet with answers?但是 Google Form 可以使用来自 Sheet 的数据和答案吗? So I think to create calculator.所以我想创建计算器。 When I debug code in script in "Sheet with answers from Form" everything works fine.当我在“带有表单答案的工作表”中的脚本中调试代码时,一切正常。 But I don't know how this script become workable when I create this code in script in the Form.但是当我在表单中的脚本中创建此代码时,我不知道此脚本如何变得可行。 Please help me.请帮我。 I want that after user press button "Send form" he get browser window with value from cell from "the Sheet with answers from the Form".我希望在用户按下“发送表单”按钮后,他会从“带有表单答案的工作表”中的单元格中获取带有值的浏览器窗口。

My code:我的代码:

function sendFormByEmail(e) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Ответы на форму (1)");
  var rows = sheet.getLastRow();
  var cols = sheet.getLastColumn();
  var sheet2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Лист4");
  var values = sheet2.getRange(rows, cols+1, 1, 1).getValue();
  Browser.msgBox("Your value: " + values + " $");  
}

Sadly, this is not possible at the moment using Google Forms.遗憾的是,目前使用 Google 表单无法做到这一点。

There is currently no way of issuing a dynamic response to the form user.目前没有办法向表单用户发出动态响应。

If you are still interested in the possibility of doing such a thing, I suggest you check out Google Apps Script WebApps , that will allow you to implement this functionality (although will also require more work).如果您仍然对做这样的事情的可能性感兴趣,我建议您查看 Google Apps Script WebApps ,这将允许您实现此功能(尽管也需要更多的工作)。

The idea is that:这个想法是:

  • You create an HTML form that can be retrieved from the Browser through the doGet() function.您创建了一个 HTML 表单,可以通过doGet()函数从浏览器中检索该表单。
  • The form submits a POST request with all the user's data, which is handled by the doPost() function.表单提交一个包含所有用户数据的 POST 请求,由doPost()函数处理。 This function inserts the data into your Sheets document by means of the SpreadsheetApp class, and returns an HTML response containing the response value.此函数通过SpreadsheetApp类将数据插入到您的表格文档中,并返回一个包含响应值的 HTML 响应。

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

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