Answer the question
In order to leave comments, you need to log in
How to pass a group of checkbox values in a form?
There is a form with checkboxes, which I pass it through Actions Google Scripts to a Google spreadsheet. If I specify one of several options, then everything works out well - the correct option is entered in the cell, if I select several, then with such a data transfer form['checkbox_name[]']
SpreadsheetApp.openById(SHEET_ID).getSheets()[0].appendRow([new Date(), form['name'], form['phone'], form['email'], form['checkbox_name[]']].concat(res));
SpreadsheetApp.openById(SHEET_ID).getSheets()[0].appendRow([new Date(), form['name'], form['phone'], form['email'], form['checkbox_name']].concat(res));
<div class="ss-form-entry">
<label class="ss-q-title" for="checkbox_name[]">Выберите необходимые виды работ <span class="ss-required-asterisk">*</span></label>
<ul class="checkbox-group required">
<li><label><span class="ss-choice-item-control goog-inline-block"><input type="checkbox" name="checkbox_name[]" value="Работа 1" class="ss-q-checkbox"></span>
<span class="ss-choice-label">Работа 1</span></label></li>
<li><label><span class="ss-choice-item-control goog-inline-block"><input type="checkbox" name="checkbox_name[]" value="Работа 2" class="ss-q-checkbox"></span>
<span class="ss-choice-label">Работа 2</span></label></li>
<li><label><span class="ss-choice-item-control goog-inline-block"><input type="checkbox" name="checkbox_name[]" value="Работа 3" class="ss-q-checkbox"></span>
<span class="ss-choice-label">Работа 3</span></label></li>
<li><label><span class="ss-choice-item-control goog-inline-block"><input type="checkbox" name="checkbox_name[]" value="Работа 4" class="ss-q-checkbox"></span>
<span class="ss-choice-label">Работа 4</span></label></li>
<li><label><span class="ss-choice-item-control goog-inline-block"><input type="checkbox" name="checkbox_name[]" value="Работа 5" class="ss-q-checkbox"></span>
<span class="ss-choice-label">Работа 5</span></label></li>
</ul>
</div>
Answer the question
In order to leave comments, you need to log in
[Ljava.lang.Object;@556935f1
is an array. Tables do not support complex types. Try casting the array to a string.
Instead
, you can
or
as a variant of the previous form['checkbox_name[]']
JSON.stringify(form['checkbox_name[]'], null, ' ')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question