我有一个包含一些复选框的表单(使用 HtmlService)。当它被提交时,它应该通过电子邮件发送内容。一切都适用于复选框值的豁免。仅发送第一个复选框值。我究竟做错了什么?我在下面添加了一个示例代码。任何帮助表示赞赏。
<form name=“some-form” action="<?= appUrl ?>" method="post”>
<input type=“hidden” name=“form_name” value=“send_form”>
<label>Your Name</label>
<input type=“text” name=“name”>
<label>Your Email</label>
<input type=“text” name=“email”>
<label>Favorite Colors</label>
<input type=“checkbox” name=“favorite_colors” value=“blue”>Blue<br/>
<input type=“checkbox” name=“favorite_colors” value=“red”>Red<br/>
<input type=“checkbox” name=“favorite_colors” value=“yellow”>Yellow<br/>
<input type=“checkbox” name=“favorite_colors” value=“green”>Green<br/>
<input type=“submit” value=“Send Form”>
</form>
// post function
function doPost(e)
{
var evaluated = undefined;
//check if right form and call send function
if(e.parameter.form_name == “send_form”)
{
evaluated = sendForm(e)
}
return evaluated;
}
// send function
function sendForm(e)
{
// data from form
var name = e.parameter.name;
var email = e.parameter.email;
var favorite_colors = e.parameter.favorite_colors;
// create and send message
var to = “some-email@gmail.com”;
var subject = “New form response”;
var body = “A new form was completed” +
“Name: “ + name +
“Email: “ + email +
“Favorite Colors: “ + email;
MailApp.SendEmail(to, subject, body);
}