Google Apps脚本e.namedValues格式多项选择 [英] Google Apps Script e.namedValues format multiple choice

查看:88
本文介绍了Google Apps脚本e.namedValues格式多项选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的脚本,通过电子邮件发送Google云端硬盘表单提交的结果。表单中的其中一个问题有多选复选框。我使用e.namedValues来获取答案数组,以便我可以通过电子邮件发送它们,如下所示:

I have a simple script that emails the results of a Google Drive form submission. One of the questions in the form has multiple choice checkboxes. I am using e.namedValues to grab the array of answers so that I can email them, like this:

var multiple = e.namedValues['Multiple Choice Question'].toString();

并且通过电子邮件发送的结果是这样的:

And the result that gets emailed is this:

Answer 1, Answer 2, Answer 3

但我想结果被格式化为这样:

But I would like the result to be formatted like this:

Answer 1
Answer 2
Answer 3

而不是用逗号分隔。有没有办法做到这一点?

Instead of separated by commas. Is there any way to do this?

推荐答案

使用JavaScript字符串的分割函数

Use JavaScript String's split function

var multiple = e.namedValues['Multiple Choice Question'].toString();
var choicesSelected = multiple.split(',');
multiple =''; 
for(var i in choicesSelected){
  multiple += choicesSelected[i] + '\n' ;
}
for (var i in multiple){
  Logger.log(multiple[i]);
}

这篇关于Google Apps脚本e.namedValues格式多项选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆