File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -19,13 +19,21 @@ function getFormData() {
19
19
var data = { } ;
20
20
fields . forEach ( function ( k ) {
21
21
data [ k ] = elements [ k ] . value ;
22
- if ( elements [ k ] . type === "checkbox" ) {
23
- data [ k ] = elements [ k ] . checked ;
24
- // special case for Edge's html collection
22
+ var str = "" ; // declare empty string outside of loop to allow
23
+ // it to be appended to for each item in the loop
24
+ if ( elements [ k ] . type === "checkbox" ) { // special case for Edge's html collection
25
+ str = str + elements [ k ] . checked + ", " ; // take the string and append
26
+ // the current checked value to
27
+ // the end of it, along with
28
+ // a comma and a space
29
+ data [ k ] = str . slice ( 0 , - 2 ) ; // remove the last comma and space
30
+ // from the string to make the output
31
+ // prettier in the spreadsheet
25
32
} else if ( elements [ k ] . length ) {
26
33
for ( var i = 0 ; i < elements [ k ] . length ; i ++ ) {
27
34
if ( elements [ k ] . item ( i ) . checked ) {
28
- data [ k ] = elements [ k ] . item ( i ) . value ;
35
+ str = str + elements [ k ] . item ( i ) . value + ", " ; // same as above
36
+ data [ k ] = str . slice ( 0 , - 2 ) ;
29
37
}
30
38
}
31
39
}
You can’t perform that action at this time.
0 commit comments