質問編集履歴
15
GASの不足部分追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,15 +28,15 @@
|
|
28
28
|
|
29
29
|
function doGet() {
|
30
30
|
|
31
|
-
|
31
|
+
return HtmlService.createTemplateFromFile('index')
|
32
|
-
|
32
|
+
|
33
|
-
|
33
|
+
.evaluate()
|
34
|
-
|
34
|
+
|
35
|
-
|
35
|
+
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
|
36
|
-
|
36
|
+
|
37
|
-
|
37
|
+
.addMetaTag('viewport', 'width=device-width, initial-scale=1')
|
38
|
-
|
38
|
+
|
39
|
-
|
39
|
+
.setTitle('gas入力フォームサンプル');
|
40
40
|
|
41
41
|
}
|
42
42
|
|
@@ -46,33 +46,27 @@
|
|
46
46
|
|
47
47
|
|
48
48
|
|
49
|
-
|
49
|
+
//Logger.log("data = %s", data);
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
-
|
53
|
+
var datasheet = SpreadsheetApp.openById('スプレッドシートID').getSheetByName('シート1');
|
54
|
-
|
54
|
+
|
55
|
-
|
55
|
+
var now = new Date();
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
-
|
59
|
+
var i = datasheet.getLastRow() + 1;
|
60
|
-
|
60
|
+
|
61
|
-
|
61
|
+
datasheet.getRange(i, 11).setValue(data[11]);
|
62
|
-
|
62
|
+
|
63
|
-
|
63
|
+
datasheet.getRange(i, 12).setValue(Utilities.formatDate(now, 'Asia/Tokyo', 'yyyy/MM/dd HH:mm:ss'));
|
64
|
-
|
65
|
-
|
64
|
+
|
66
|
-
|
67
|
-
|
65
|
+
result = true;
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
66
|
+
|
72
|
-
|
67
|
+
|
68
|
+
|
73
|
-
|
69
|
+
return {data: true};
|
74
|
-
|
75
|
-
};
|
76
70
|
|
77
71
|
}
|
78
72
|
|
@@ -80,171 +74,309 @@
|
|
80
74
|
|
81
75
|
function getSelectListFromMasterSS() {
|
82
76
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
77
|
+
var selectList = [];
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
// マスタデータシートを取得
|
82
|
+
|
83
|
+
var datasheet = SpreadsheetApp.openById('スプレッドシートID').getSheetByName('マスタ');
|
84
|
+
|
85
|
+
// B列2行目のデータからB列の最終行までを取得
|
86
|
+
|
87
|
+
var lastRow = datasheet.getRange("A:A").getValues().filter(String).length - 1;
|
88
|
+
|
89
|
+
//Logger.log("lastRow = %s", lastRow);
|
90
|
+
|
91
|
+
// B列2行目のデータからB列の最終行までを1列だけ取得
|
92
|
+
|
93
|
+
selectList = datasheet.getRange(2, 1, lastRow, 1).getValues();
|
94
|
+
|
95
|
+
//Logger.log("selectList = %s", selectList);
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
return {data: selectList};
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
function Test(text) {
|
108
|
+
|
109
|
+
// マスタデータシートを取得
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
var datasheet = SpreadsheetApp.openById('スプレッドシートID').getSheetByName('マスタ');
|
116
|
+
|
117
|
+
var range = datasheet.getRange("A:A").getValues();
|
118
|
+
|
119
|
+
var lastRow = range.filter(String).length;
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
var loginData = datasheet.getRange(2, 1, lastRow, 3).getValues(); //2~lastRow行目、3列分を二次元配列として取得
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
loginData = loginData.filter(function(v) {
|
130
|
+
|
131
|
+
return v[0] == text;
|
132
|
+
|
133
|
+
});
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
Logger.log(loginData)
|
138
|
+
|
139
|
+
//↑ここのログに出力された値(v[1]のみ)をHTML表示したいです
|
140
|
+
|
141
|
+
//return {data: loginData};
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
```
|
154
|
+
|
155
|
+
【javascript.html】
|
156
|
+
|
157
|
+
```
|
158
|
+
|
159
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
160
|
+
|
161
|
+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
|
162
|
+
|
163
|
+
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
|
164
|
+
|
165
|
+
crossorigin="anonymous"></script>
|
166
|
+
|
167
|
+
<script src="https://use.fontawesome.com/7bcbed1321.js"></script>
|
168
|
+
|
169
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
|
170
|
+
|
171
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.1/js/bootstrap-select.min.js"></script>
|
172
|
+
|
173
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.8/validator.min.js"></script>
|
174
|
+
|
175
|
+
<script>
|
176
|
+
|
177
|
+
/**
|
178
|
+
|
179
|
+
コード.jsのgetSelectListFromSS()を読んで、スプレッドシートのデータをもとに、セレクトボックスを構築する
|
180
|
+
|
181
|
+
*/
|
182
|
+
|
183
|
+
function getSelectList() {
|
184
|
+
|
185
|
+
try {
|
186
|
+
|
187
|
+
google.script.run
|
188
|
+
|
189
|
+
.withSuccessHandler(function(result) {
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
console.log("result", result);
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
var select = document.getElementById('select_id3');
|
198
|
+
|
199
|
+
var option = document.createElement('option');
|
200
|
+
|
201
|
+
option.setAttribute('value', '');
|
202
|
+
|
203
|
+
option.setAttribute('selected', true);
|
204
|
+
|
205
|
+
option.innerHTML = '未選択';
|
206
|
+
|
207
|
+
select.appendChild(option);
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
for (var i = 0; i < result.data.length; i++) {
|
212
|
+
|
213
|
+
option = document.createElement('option');
|
214
|
+
|
215
|
+
option.setAttribute('value', i + 1);
|
216
|
+
|
217
|
+
option.innerHTML = result.data[i];
|
218
|
+
|
219
|
+
select.appendChild(option);
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
})
|
228
|
+
|
229
|
+
.withFailureHandler(function(result) {
|
230
|
+
|
231
|
+
toastr.error('リストの取得に失敗しました。', result);
|
232
|
+
|
233
|
+
})
|
234
|
+
|
235
|
+
.getSelectListFromMasterSS();
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
} catch (e) {
|
240
|
+
|
241
|
+
toastr.error(e);
|
116
242
|
|
117
243
|
}
|
118
244
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
l
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
245
|
+
}
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
/**
|
250
|
+
|
251
|
+
コード.jsのregisterSSByFormData()を呼んで、フォームの内容をスプレッドシートに登録する
|
252
|
+
|
253
|
+
*/
|
254
|
+
|
255
|
+
function sendData() {
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
try {
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
processing(true);
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
var elemntIFrame = window.parent.document.getElementById('userHtmlFrame');
|
268
|
+
|
269
|
+
elemntIFrame.setAttribute('scrolling', 'no');
|
270
|
+
|
271
|
+
elemntIFrame.setAttribute('frameborder', '0');
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
var data = [];
|
276
|
+
|
277
|
+
data[0] = 'dummy';
|
278
|
+
|
279
|
+
data[11] = document.getElementById('select_id3').options[document.getElementById(
|
280
|
+
|
281
|
+
'select_id3').selectedIndex].text;
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
console.log("data", data);
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
google.script.run
|
292
|
+
|
293
|
+
.withSuccessHandler(function(result) {
|
294
|
+
|
295
|
+
processing(false);
|
296
|
+
|
297
|
+
if (result.data) {
|
298
|
+
|
299
|
+
toastr.info('送信完了');
|
300
|
+
|
301
|
+
} else {
|
302
|
+
|
303
|
+
toastr.error('送信失敗しました');
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
})
|
308
|
+
|
309
|
+
.withFailureHandler(function(result) {
|
310
|
+
|
311
|
+
processing(false);
|
312
|
+
|
313
|
+
toastr.error('データ送信に失敗しました。', result);
|
314
|
+
|
315
|
+
})
|
316
|
+
|
317
|
+
.registerSSByFormData(data);
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
} catch (e) {
|
322
|
+
|
323
|
+
processing(false);
|
324
|
+
|
325
|
+
toastr.error(e);
|
156
326
|
|
157
327
|
}
|
158
328
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
/
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
option.innerHTML = '未選択';
|
212
|
-
|
213
|
-
select.appendChild(option);
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
for (var i = 0; i < result.data.length; i++) {
|
218
|
-
|
219
|
-
option = document.createElement('option');
|
220
|
-
|
221
|
-
option.setAttribute('value', i + 1);
|
222
|
-
|
223
|
-
option.innerHTML = result.data[i];
|
224
|
-
|
225
|
-
select.appendChild(option);
|
226
|
-
|
227
|
-
}
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
})
|
234
|
-
|
235
|
-
.withFailureHandler(function(result) {
|
236
|
-
|
237
|
-
toastr.error('リストの取得に失敗しました。', result);
|
238
|
-
|
239
|
-
})
|
240
|
-
|
241
|
-
.getSelectListFromMasterSS();
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
} catch (e) {
|
246
|
-
|
247
|
-
toastr.error(e);
|
329
|
+
|
330
|
+
|
331
|
+
}
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
//ここでHTMLでセレクトした値をGASへ送信
|
336
|
+
|
337
|
+
function outputSelectedValueAndText(obj) {
|
338
|
+
|
339
|
+
/*
|
340
|
+
|
341
|
+
* obj は select タグであり、selectedIndex プロパティには
|
342
|
+
|
343
|
+
* 変更後の選択項目のインデックスが格納されています
|
344
|
+
|
345
|
+
*/
|
346
|
+
|
347
|
+
var idx = obj.selectedIndex;
|
348
|
+
|
349
|
+
var text = obj.options[idx].text; // 表示テキスト
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
// 値をコンソールに出力 (ここで「コード.gs 」 Testイベントへ)
|
354
|
+
|
355
|
+
google.script.run.Test(text);
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
}
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
// 処理中アイコン表示・非表示
|
366
|
+
|
367
|
+
function processing(processing) {
|
368
|
+
|
369
|
+
if (processing) {
|
370
|
+
|
371
|
+
document.getElementById('processing').style.visibility = "visible";
|
372
|
+
|
373
|
+
document.getElementById('send_button').setAttribute("disabled", true);
|
374
|
+
|
375
|
+
} else {
|
376
|
+
|
377
|
+
document.getElementById('processing').style.visibility = "hidden";
|
378
|
+
|
379
|
+
document.getElementById('send_button').removeAttribute("disabled");
|
248
380
|
|
249
381
|
}
|
250
382
|
|
@@ -252,144 +384,6 @@
|
|
252
384
|
|
253
385
|
|
254
386
|
|
255
|
-
/**
|
256
|
-
|
257
|
-
コード.jsのregisterSSByFormData()を呼んで、フォームの内容をスプレッドシートに登録する
|
258
|
-
|
259
|
-
*/
|
260
|
-
|
261
|
-
function sendData() {
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
try {
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
processing(true);
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
var elemntIFrame = window.parent.document.getElementById('userHtmlFrame');
|
274
|
-
|
275
|
-
elemntIFrame.setAttribute('scrolling', 'no');
|
276
|
-
|
277
|
-
elemntIFrame.setAttribute('frameborder', '0');
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
var data = [];
|
282
|
-
|
283
|
-
data[0] = 'dummy';
|
284
|
-
|
285
|
-
data[11] = document.getElementById('select_id3').options[document.getElementById(
|
286
|
-
|
287
|
-
'select_id3').selectedIndex].text;
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
console.log("data", data);
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
google.script.run
|
298
|
-
|
299
|
-
.withSuccessHandler(function(result) {
|
300
|
-
|
301
|
-
processing(false);
|
302
|
-
|
303
|
-
if (result.data) {
|
304
|
-
|
305
|
-
toastr.info('送信完了');
|
306
|
-
|
307
|
-
} else {
|
308
|
-
|
309
|
-
toastr.error('送信失敗しました');
|
310
|
-
|
311
|
-
}
|
312
|
-
|
313
|
-
})
|
314
|
-
|
315
|
-
.withFailureHandler(function(result) {
|
316
|
-
|
317
|
-
processing(false);
|
318
|
-
|
319
|
-
toastr.error('データ送信に失敗しました。', result);
|
320
|
-
|
321
|
-
})
|
322
|
-
|
323
|
-
.registerSSByFormData(data);
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
} catch (e) {
|
328
|
-
|
329
|
-
processing(false);
|
330
|
-
|
331
|
-
toastr.error(e);
|
332
|
-
|
333
|
-
}
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
}
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
//ここでHTMLでセレクトした値をGASへ送信
|
342
|
-
|
343
|
-
function outputSelectedValueAndText(obj) {
|
344
|
-
|
345
|
-
/*
|
346
|
-
|
347
|
-
* obj は select タグであり、selectedIndex プロパティには
|
348
|
-
|
349
|
-
* 変更後の選択項目のインデックスが格納されています
|
350
|
-
|
351
|
-
*/
|
352
|
-
|
353
|
-
var idx = obj.selectedIndex;
|
354
|
-
|
355
|
-
var text = obj.options[idx].text; // 表示テキスト
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
// 値をコンソールに出力 (ここで「コード.gs 」 Testイベントへ)
|
360
|
-
|
361
|
-
google.script.run.Test(text);
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
}
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
// 処理中アイコン表示・非表示
|
372
|
-
|
373
|
-
function processing(processing) {
|
374
|
-
|
375
|
-
if (processing) {
|
376
|
-
|
377
|
-
document.getElementById('processing').style.visibility = "visible";
|
378
|
-
|
379
|
-
document.getElementById('send_button').setAttribute("disabled", true);
|
380
|
-
|
381
|
-
} else {
|
382
|
-
|
383
|
-
document.getElementById('processing').style.visibility = "hidden";
|
384
|
-
|
385
|
-
document.getElementById('send_button').removeAttribute("disabled");
|
386
|
-
|
387
|
-
}
|
388
|
-
|
389
|
-
}
|
390
|
-
|
391
|
-
|
392
|
-
|
393
387
|
// ロード完了後の処理
|
394
388
|
|
395
389
|
$(function() {
|
14
スタイルシートの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -523,3 +523,19 @@
|
|
523
523
|
</html>
|
524
524
|
|
525
525
|
```
|
526
|
+
|
527
|
+
【stylesheet.html】
|
528
|
+
|
529
|
+
```
|
530
|
+
|
531
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
532
|
+
|
533
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
534
|
+
|
535
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" crossorigin="anonymous">
|
536
|
+
|
537
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.1/css/bootstrap-select.min.css">
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
```
|
13
追記のため
test
CHANGED
File without changes
|
test
CHANGED
@@ -490,6 +490,10 @@
|
|
490
490
|
|
491
491
|
</div>
|
492
492
|
|
493
|
+
<!--このあたりに「コード.gs」 function Test(text)のloginData(v[1])の値を表示したいです。-->
|
494
|
+
|
495
|
+
|
496
|
+
|
493
497
|
|
494
498
|
|
495
499
|
<div class="form-group">
|
12
formが消えていました・・
test
CHANGED
File without changes
|
test
CHANGED
@@ -516,4 +516,6 @@
|
|
516
516
|
|
517
517
|
</body>
|
518
518
|
|
519
|
-
</html>
|
519
|
+
</html>
|
520
|
+
|
521
|
+
```
|
11
formが消えていました・・
test
CHANGED
File without changes
|
test
CHANGED
@@ -450,96 +450,70 @@
|
|
450
450
|
|
451
451
|
<html lang="ja">
|
452
452
|
|
453
|
-
|
454
|
-
|
455
453
|
<head>
|
456
454
|
|
457
|
-
|
455
|
+
<meta charset="utf-8">
|
458
|
-
|
456
|
+
|
459
|
-
|
457
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
460
|
-
|
458
|
+
|
461
|
-
|
459
|
+
<?!= HtmlService.createHtmlOutputFromFile('stylesheet').getContent(); ?>
|
462
460
|
|
463
461
|
</head>
|
464
462
|
|
465
|
-
|
466
|
-
|
467
463
|
<body>
|
468
464
|
|
469
465
|
|
470
466
|
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
<button id="send_button" type="submit" class="btn btn-primary btn-large">
|
522
|
-
|
523
|
-
<i class="fa fa-send fa-lg"></i>送信
|
524
|
-
|
525
|
-
</button>
|
526
|
-
|
527
|
-
</div>
|
528
|
-
|
529
|
-
</div>
|
530
|
-
|
531
|
-
</form>
|
532
|
-
|
533
|
-
<i id="processing" class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
|
534
|
-
|
535
|
-
</div>
|
536
|
-
|
537
|
-
<?!= HtmlService.createHtmlOutputFromFile('javascript').getContent(); ?>
|
467
|
+
<nav class="navbar navbar-inverse">
|
468
|
+
|
469
|
+
<div class="navbar-header"><a class="navbar-brand" href="#">入力フォーム</a></div>
|
470
|
+
|
471
|
+
</nav>
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
<div class="container">
|
476
|
+
|
477
|
+
<form class="form-horizontal" id="myForm" name="myForm" onsubmit="return false;">
|
478
|
+
|
479
|
+
<div class="form-group">
|
480
|
+
|
481
|
+
<label class="control-label col-xs-3">セレクトボックス(動的)</label>
|
482
|
+
|
483
|
+
<div class="col-xs-9">
|
484
|
+
|
485
|
+
<select class="form-control" id="select_id3" name="select_id3" onchange="outputSelectedValueAndText(this);"></select>
|
486
|
+
|
487
|
+
<div class="help-block with-errors"></div>
|
488
|
+
|
489
|
+
</div>
|
490
|
+
|
491
|
+
</div>
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
<div class="form-group">
|
496
|
+
|
497
|
+
<div class="col-xs-offset-3 col-xs-9">
|
498
|
+
|
499
|
+
<button id="send_button" type="submit" class="btn btn-primary btn-large">
|
500
|
+
|
501
|
+
<i class="fa fa-send fa-lg"></i>送信
|
502
|
+
|
503
|
+
</button>
|
504
|
+
|
505
|
+
</div>
|
506
|
+
|
507
|
+
</div>
|
508
|
+
|
509
|
+
</form>
|
510
|
+
|
511
|
+
<i id="processing" class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
|
512
|
+
|
513
|
+
</div>
|
514
|
+
|
515
|
+
<?!= HtmlService.createHtmlOutputFromFile('javascript').getContent(); ?>
|
538
516
|
|
539
517
|
</body>
|
540
518
|
|
541
|
-
|
542
|
-
|
543
|
-
</html>
|
519
|
+
</html>```
|
544
|
-
|
545
|
-
```
|
10
質問内容の解決した箇所の削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,12 +12,6 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
-
google.script.runを使えばセレクトボックス内の値をGASへ渡せると思ったのですが
|
16
|
-
|
17
|
-
ログには表示されませんでした(値が渡せていない状態)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
15
|
セレクトボックス内の値を選択した瞬間に、その値をGASへ渡して値を基にスプレッドシート内を検索して
|
22
16
|
|
23
17
|
その結果をHTMLのセレクトボックスの下箇所へ表示させるにはどうしたらよいでしょうか。
|
9
インデントの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,15 +34,15 @@
|
|
34
34
|
|
35
35
|
function doGet() {
|
36
36
|
|
37
|
-
|
37
|
+
return HtmlService.createTemplateFromFile('index')
|
38
|
-
|
38
|
+
|
39
|
-
|
39
|
+
.evaluate()
|
40
|
-
|
40
|
+
|
41
|
-
|
41
|
+
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
|
42
|
-
|
42
|
+
|
43
|
-
|
43
|
+
.addMetaTag('viewport', 'width=device-width, initial-scale=1')
|
44
|
-
|
44
|
+
|
45
|
-
|
45
|
+
.setTitle('gas入力フォームサンプル');
|
46
46
|
|
47
47
|
}
|
48
48
|
|
@@ -52,27 +52,33 @@
|
|
52
52
|
|
53
53
|
|
54
54
|
|
55
|
-
|
55
|
+
Logger.log("data = %s", data);
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
-
|
59
|
+
var datasheet = SpreadsheetApp.openById('スプレッドシートID').getSheetByName('シート1');
|
60
|
-
|
60
|
+
|
61
|
-
|
61
|
+
var now = new Date();
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
-
|
65
|
+
var i = datasheet.getLastRow() + 1;
|
66
|
-
|
66
|
+
|
67
|
-
|
67
|
+
datasheet.getRange(i, 11).setValue(data[11]);
|
68
|
-
|
68
|
+
|
69
|
-
|
69
|
+
datasheet.getRange(i, 12).setValue(Utilities.formatDate(now, 'Asia/Tokyo',
|
70
|
+
|
70
|
-
|
71
|
+
'yyyy/MM/dd HH:mm:ss'));
|
72
|
+
|
71
|
-
|
73
|
+
result = true;
|
74
|
+
|
75
|
+
|
76
|
+
|
72
|
-
|
77
|
+
return {
|
73
|
-
|
74
|
-
|
78
|
+
|
75
|
-
|
79
|
+
data: true
|
80
|
+
|
81
|
+
};
|
76
82
|
|
77
83
|
}
|
78
84
|
|
@@ -80,442 +86,466 @@
|
|
80
86
|
|
81
87
|
function getSelectListFromMasterSS() {
|
82
88
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
89
|
+
var selectList = [];
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
// マスタデータシートを取得
|
94
|
+
|
95
|
+
var datasheet = SpreadsheetApp.openById('スプレッドシートID'
|
96
|
+
|
97
|
+
').getSheetByName('
|
98
|
+
|
99
|
+
マスタ ');
|
100
|
+
|
101
|
+
// B列2行目のデータからB列の最終行までを取得
|
102
|
+
|
103
|
+
var lastRow = datasheet.getRange("A:A").getValues().filter(String).length -
|
104
|
+
|
105
|
+
1;
|
106
|
+
|
107
|
+
//Logger.log("lastRow = %s", lastRow);
|
108
|
+
|
109
|
+
// B列2行目のデータからB列の最終行までを1列だけ取得
|
110
|
+
|
111
|
+
selectList = datasheet.getRange(2, 1, lastRow, 1).getValues();
|
112
|
+
|
113
|
+
//Logger.log("selectList = %s", selectList);
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
return {
|
118
|
+
|
119
|
+
data: selectList
|
120
|
+
|
121
|
+
};
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
function Test(text) {
|
130
|
+
|
131
|
+
// マスタデータシートを取得
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
var datasheet = SpreadsheetApp.openById('スプレッドシートID').getSheetByName('マスタ');
|
138
|
+
|
139
|
+
var range = datasheet.getRange("A:A").getValues();
|
140
|
+
|
141
|
+
var lastRow = range.filter(String).length;
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
var loginData = datasheet.getRange(2, 1, lastRow, 3).getValues(); //2~lastRow行目、3列分を二次元配列として取得
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
loginData = loginData.filter(function(v) {
|
150
|
+
|
151
|
+
return v[0] == text;
|
152
|
+
|
153
|
+
}); //入力店コードデータのみ抽出
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
Logger.log(loginData)
|
158
|
+
|
159
|
+
//↑ここのログに出力された値(v[1]のみ)をHTML表示したいです
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
```
|
166
|
+
|
167
|
+
【javascript.html】
|
168
|
+
|
169
|
+
```
|
170
|
+
|
171
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
172
|
+
|
173
|
+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
|
174
|
+
|
175
|
+
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
|
176
|
+
|
177
|
+
crossorigin="anonymous"></script>
|
178
|
+
|
179
|
+
<script src="https://use.fontawesome.com/7bcbed1321.js"></script>
|
180
|
+
|
181
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
|
182
|
+
|
183
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.1/js/bootstrap-select.min.js"></script>
|
184
|
+
|
185
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.8/validator.min.js"></script>
|
186
|
+
|
187
|
+
<script>
|
188
|
+
|
189
|
+
/**
|
190
|
+
|
191
|
+
コード.jsのgetSelectListFromSS()を読んで、スプレッドシートのデータをもとに、セレクトボックスを構築する
|
192
|
+
|
193
|
+
*/
|
194
|
+
|
195
|
+
function getSelectList() {
|
196
|
+
|
197
|
+
try {
|
198
|
+
|
199
|
+
google.script.run
|
200
|
+
|
201
|
+
.withSuccessHandler(function(result) {
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
console.log("result", result);
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
var select = document.getElementById('select_id3');
|
210
|
+
|
211
|
+
var option = document.createElement('option');
|
212
|
+
|
213
|
+
option.setAttribute('value', '');
|
214
|
+
|
215
|
+
option.setAttribute('selected', true);
|
216
|
+
|
217
|
+
option.innerHTML = '未選択';
|
218
|
+
|
219
|
+
select.appendChild(option);
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
for (var i = 0; i < result.data.length; i++) {
|
224
|
+
|
225
|
+
option = document.createElement('option');
|
226
|
+
|
227
|
+
option.setAttribute('value', i + 1);
|
228
|
+
|
229
|
+
option.innerHTML = result.data[i];
|
230
|
+
|
231
|
+
select.appendChild(option);
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
})
|
240
|
+
|
241
|
+
.withFailureHandler(function(result) {
|
242
|
+
|
243
|
+
toastr.error('リストの取得に失敗しました。', result);
|
244
|
+
|
245
|
+
})
|
246
|
+
|
247
|
+
.getSelectListFromMasterSS();
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
} catch (e) {
|
252
|
+
|
253
|
+
toastr.error(e);
|
254
|
+
|
255
|
+
}
|
106
256
|
|
107
257
|
}
|
108
258
|
|
109
259
|
|
110
260
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
var l
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
l
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
261
|
+
/**
|
262
|
+
|
263
|
+
コード.jsのregisterSSByFormData()を呼んで、フォームの内容をスプレッドシートに登録する
|
264
|
+
|
265
|
+
*/
|
266
|
+
|
267
|
+
function sendData() {
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
try {
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
processing(true);
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
var elemntIFrame = window.parent.document.getElementById('userHtmlFrame');
|
280
|
+
|
281
|
+
elemntIFrame.setAttribute('scrolling', 'no');
|
282
|
+
|
283
|
+
elemntIFrame.setAttribute('frameborder', '0');
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
var data = [];
|
288
|
+
|
289
|
+
data[0] = 'dummy';
|
290
|
+
|
291
|
+
data[11] = document.getElementById('select_id3').options[document.getElementById(
|
292
|
+
|
293
|
+
'select_id3').selectedIndex].text;
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
console.log("data", data);
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
google.script.run
|
304
|
+
|
305
|
+
.withSuccessHandler(function(result) {
|
306
|
+
|
307
|
+
processing(false);
|
308
|
+
|
309
|
+
if (result.data) {
|
310
|
+
|
311
|
+
toastr.info('送信完了');
|
312
|
+
|
313
|
+
} else {
|
314
|
+
|
315
|
+
toastr.error('送信失敗しました');
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
})
|
320
|
+
|
321
|
+
.withFailureHandler(function(result) {
|
322
|
+
|
323
|
+
processing(false);
|
324
|
+
|
325
|
+
toastr.error('データ送信に失敗しました。', result);
|
326
|
+
|
327
|
+
})
|
328
|
+
|
329
|
+
.registerSSByFormData(data);
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
} catch (e) {
|
334
|
+
|
335
|
+
processing(false);
|
336
|
+
|
337
|
+
toastr.error(e);
|
338
|
+
|
339
|
+
}
|
144
340
|
|
145
341
|
|
146
342
|
|
147
343
|
}
|
148
344
|
|
345
|
+
|
346
|
+
|
347
|
+
//ここでHTMLでセレクトした値をGASへ送信
|
348
|
+
|
349
|
+
function outputSelectedValueAndText(obj) {
|
350
|
+
|
351
|
+
/*
|
352
|
+
|
353
|
+
* obj は select タグであり、selectedIndex プロパティには
|
354
|
+
|
355
|
+
* 変更後の選択項目のインデックスが格納されています
|
356
|
+
|
357
|
+
*/
|
358
|
+
|
359
|
+
var idx = obj.selectedIndex;
|
360
|
+
|
361
|
+
var text = obj.options[idx].text; // 表示テキスト
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
// 値をコンソールに出力 (ここで「コード.gs 」 Testイベントへ)
|
366
|
+
|
367
|
+
google.script.run.Test(text);
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
}
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
// 処理中アイコン表示・非表示
|
378
|
+
|
379
|
+
function processing(processing) {
|
380
|
+
|
381
|
+
if (processing) {
|
382
|
+
|
383
|
+
document.getElementById('processing').style.visibility = "visible";
|
384
|
+
|
385
|
+
document.getElementById('send_button').setAttribute("disabled", true);
|
386
|
+
|
387
|
+
} else {
|
388
|
+
|
389
|
+
document.getElementById('processing').style.visibility = "hidden";
|
390
|
+
|
391
|
+
document.getElementById('send_button').removeAttribute("disabled");
|
392
|
+
|
393
|
+
}
|
394
|
+
|
395
|
+
}
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
// ロード完了後の処理
|
400
|
+
|
401
|
+
$(function() {
|
402
|
+
|
403
|
+
// トースト通知の位置指定
|
404
|
+
|
405
|
+
toastr.options.positionClass = "toast-bottom-left";
|
406
|
+
|
407
|
+
// バリデーションチェック有効化
|
408
|
+
|
409
|
+
$('#myForm').validator();
|
410
|
+
|
411
|
+
// 処理中アイコン非表示
|
412
|
+
|
413
|
+
processing(false);
|
414
|
+
|
415
|
+
// セレクトボックスのリストを動的に取得する
|
416
|
+
|
417
|
+
getSelectList();
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
// submit時のイベント登録
|
422
|
+
|
423
|
+
$('#myForm').validator().on('submit', function(e) {
|
424
|
+
|
425
|
+
if (document.getElementById('send_button').className.indexOf("disabled") !=
|
426
|
+
|
427
|
+
-1) {
|
428
|
+
|
429
|
+
// submit用のボタンのスタイルにdisabledが設定されていればバリデーションエラー
|
430
|
+
|
431
|
+
} else {
|
432
|
+
|
433
|
+
// バリデーションエラーでなければ送信
|
434
|
+
|
435
|
+
sendData();
|
436
|
+
|
437
|
+
}
|
438
|
+
|
439
|
+
})
|
440
|
+
|
441
|
+
});
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
</script>
|
446
|
+
|
447
|
+
|
448
|
+
|
149
449
|
```
|
150
450
|
|
151
|
-
【
|
451
|
+
【index.HTML】
|
152
452
|
|
153
453
|
```
|
154
454
|
|
155
|
-
<
|
156
|
-
|
157
|
-
<
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
<
|
162
|
-
|
163
|
-
<
|
164
|
-
|
165
|
-
<
|
166
|
-
|
167
|
-
<
|
168
|
-
|
169
|
-
/
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
/
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
try {
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
processing(true);
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
var elemntIFrame = window.parent.document.getElementById('userHtmlFrame');
|
260
|
-
|
261
|
-
elemntIFrame.setAttribute('scrolling', 'no');
|
262
|
-
|
263
|
-
elemntIFrame.setAttribute('frameborder', '0');
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
var data = [];
|
268
|
-
|
269
|
-
data[0] = 'dummy';
|
270
|
-
|
271
|
-
data[11] = document.getElementById('select_id3').options[document.getElementById('select_id3').selectedIndex].text;
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
console.log("data", data);
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
google.script.run
|
282
|
-
|
283
|
-
.withSuccessHandler(function(result) {
|
284
|
-
|
285
|
-
processing(false);
|
286
|
-
|
287
|
-
if (result.data) {
|
288
|
-
|
289
|
-
toastr.info('送信完了');
|
290
|
-
|
291
|
-
} else {
|
292
|
-
|
293
|
-
toastr.error('送信失敗しました');
|
294
|
-
|
295
|
-
}
|
296
|
-
|
297
|
-
})
|
298
|
-
|
299
|
-
.withFailureHandler(function(result) {
|
300
|
-
|
301
|
-
processing(false);
|
302
|
-
|
303
|
-
toastr.error('データ送信に失敗しました。', result);
|
304
|
-
|
305
|
-
})
|
306
|
-
|
307
|
-
.registerSSByFormData(data);
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
} catch (e) {
|
312
|
-
|
313
|
-
processing(false);
|
314
|
-
|
315
|
-
toastr.error(e);
|
316
|
-
|
317
|
-
}
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
}
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
//ここでHTMLでセレクトした値をGASへ送信
|
326
|
-
|
327
|
-
function outputSelectedValueAndText(obj)
|
328
|
-
|
329
|
-
{
|
330
|
-
|
331
|
-
/*
|
332
|
-
|
333
|
-
* obj は select タグであり、selectedIndex プロパティには
|
334
|
-
|
335
|
-
* 変更後の選択項目のインデックスが格納されています
|
336
|
-
|
337
|
-
*/
|
338
|
-
|
339
|
-
var idx = obj.selectedIndex;
|
340
|
-
|
341
|
-
var text = obj.options[idx].text; // 表示テキスト
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
// 値をコンソールに出力 (ここで「コード.gs 」 Testイベントへ)
|
346
|
-
|
347
|
-
google.script.run.Test(text);
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
}
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
// 処理中アイコン表示・非表示
|
358
|
-
|
359
|
-
function processing(processing) {
|
360
|
-
|
361
|
-
if (processing) {
|
362
|
-
|
363
|
-
document.getElementById('processing').style.visibility = "visible";
|
364
|
-
|
365
|
-
document.getElementById('send_button').setAttribute("disabled", true);
|
366
|
-
|
367
|
-
} else {
|
368
|
-
|
369
|
-
document.getElementById('processing').style.visibility = "hidden";
|
370
|
-
|
371
|
-
document.getElementById('send_button').removeAttribute("disabled");
|
372
|
-
|
373
|
-
}
|
374
|
-
|
375
|
-
}
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
// ロード完了後の処理
|
380
|
-
|
381
|
-
$(function() {
|
382
|
-
|
383
|
-
// トースト通知の位置指定
|
384
|
-
|
385
|
-
toastr.options.positionClass = "toast-bottom-left";
|
386
|
-
|
387
|
-
// バリデーションチェック有効化
|
388
|
-
|
389
|
-
$('#myForm').validator();
|
390
|
-
|
391
|
-
// 処理中アイコン非表示
|
392
|
-
|
393
|
-
processing(false);
|
394
|
-
|
395
|
-
// セレクトボックスのリストを動的に取得する
|
396
|
-
|
397
|
-
getSelectList();
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
// submit時のイベント登録
|
402
|
-
|
403
|
-
$('#myForm').validator().on('submit', function(e) {
|
404
|
-
|
405
|
-
if (document.getElementById('send_button').className.indexOf("disabled") != -1) {
|
406
|
-
|
407
|
-
// submit用のボタンのスタイルにdisabledが設定されていればバリデーションエラー
|
408
|
-
|
409
|
-
} else {
|
410
|
-
|
411
|
-
// バリデーションエラーでなければ送信
|
412
|
-
|
413
|
-
sendData();
|
414
|
-
|
415
|
-
}
|
416
|
-
|
417
|
-
})
|
418
|
-
|
419
|
-
});
|
420
|
-
|
421
|
-
</script>
|
422
|
-
|
423
|
-
|
455
|
+
<!DOCTYPE html>
|
456
|
+
|
457
|
+
<html lang="ja">
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
<head>
|
462
|
+
|
463
|
+
<meta charset="utf-8">
|
464
|
+
|
465
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
466
|
+
|
467
|
+
<?!= HtmlService.createHtmlOutputFromFile('stylesheet').getContent(); ?>
|
468
|
+
|
469
|
+
</head>
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
<body>
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
<nav class="navbar navbar-inverse">
|
478
|
+
|
479
|
+
<div class="navbar-header"><a class="navbar-brand" href="#">入力フォーム</a></div>
|
480
|
+
|
481
|
+
</nav>
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
<div class="container">
|
486
|
+
|
487
|
+
<form class="form-horizontal" id="myForm" name="myForm" onsubmit="return false;">
|
488
|
+
|
489
|
+
<div class="form-group">
|
490
|
+
|
491
|
+
<label class="control-label col-xs-3">セレクトボックス(動的)</label>
|
492
|
+
|
493
|
+
<div class="col-xs-9">
|
494
|
+
|
495
|
+
<select class="form-control" id="select_id3" name="select_id3" onchange="outputSelectedValueAndText(this);"></select>
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
<!--上記セレクトボックスにて選択時javascript.hymlのoutputSelectedValueAndTextイベントへ-->
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
<div class="help-block with-errors"></div>
|
506
|
+
|
507
|
+
</div>
|
508
|
+
|
509
|
+
</div>
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
<!--このあたりに「コード.gs」 function Test(text)のloginData(v[1])の値を表示したいです。-->
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
<div class="form-group">
|
524
|
+
|
525
|
+
<div class="col-xs-offset-3 col-xs-9">
|
526
|
+
|
527
|
+
<button id="send_button" type="submit" class="btn btn-primary btn-large">
|
528
|
+
|
529
|
+
<i class="fa fa-send fa-lg"></i>送信
|
530
|
+
|
531
|
+
</button>
|
532
|
+
|
533
|
+
</div>
|
534
|
+
|
535
|
+
</div>
|
536
|
+
|
537
|
+
</form>
|
538
|
+
|
539
|
+
<i id="processing" class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
|
540
|
+
|
541
|
+
</div>
|
542
|
+
|
543
|
+
<?!= HtmlService.createHtmlOutputFromFile('javascript').getContent(); ?>
|
544
|
+
|
545
|
+
</body>
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
</html>
|
424
550
|
|
425
551
|
```
|
426
|
-
|
427
|
-
【index.HTML】
|
428
|
-
|
429
|
-
```
|
430
|
-
|
431
|
-
<!DOCTYPE html>
|
432
|
-
|
433
|
-
<html lang="ja">
|
434
|
-
|
435
|
-
<head>
|
436
|
-
|
437
|
-
<meta charset="utf-8">
|
438
|
-
|
439
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
440
|
-
|
441
|
-
<?!= HtmlService.createHtmlOutputFromFile('stylesheet').getContent(); ?>
|
442
|
-
|
443
|
-
</head>
|
444
|
-
|
445
|
-
<body>
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
<nav class="navbar navbar-inverse">
|
450
|
-
|
451
|
-
<div class="navbar-header"><a class="navbar-brand" href="#">入力フォーム</a></div>
|
452
|
-
|
453
|
-
</nav>
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
<div class="container">
|
458
|
-
|
459
|
-
<form class="form-horizontal" id="myForm" name="myForm" onsubmit="return false;">
|
460
|
-
|
461
|
-
<div class="form-group">
|
462
|
-
|
463
|
-
<label class="control-label col-xs-3">セレクトボックス(動的)</label>
|
464
|
-
|
465
|
-
<div class="col-xs-9">
|
466
|
-
|
467
|
-
<select class="form-control" id="select_id3" name="select_id3" onchange="outputSelectedValueAndText(this);"></select>
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
<!--上記セレクトボックスにて選択時javascript.hymlのoutputSelectedValueAndTextイベントへ-->
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
<div class="help-block with-errors"></div>
|
476
|
-
|
477
|
-
</div>
|
478
|
-
|
479
|
-
</div>
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
<!--このあたりに「コード.gs」 function Test(text)のloginData(v[1])の値を表示したいです。-->
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
<div class="form-group">
|
492
|
-
|
493
|
-
<div class="col-xs-offset-3 col-xs-9">
|
494
|
-
|
495
|
-
<button id="send_button" type="submit" class="btn btn-primary btn-large">
|
496
|
-
|
497
|
-
<i class="fa fa-send fa-lg"></i>送信
|
498
|
-
|
499
|
-
</button>
|
500
|
-
|
501
|
-
</div>
|
502
|
-
|
503
|
-
</div>
|
504
|
-
|
505
|
-
</form>
|
506
|
-
|
507
|
-
<i id="processing" class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
|
508
|
-
|
509
|
-
</div>
|
510
|
-
|
511
|
-
<?!= HtmlService.createHtmlOutputFromFile('javascript').getContent(); ?>
|
512
|
-
|
513
|
-
</body>
|
514
|
-
|
515
|
-
</html>
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
```
|
8
修正のため
test
CHANGED
File without changes
|
test
CHANGED
@@ -86,7 +86,7 @@
|
|
86
86
|
|
87
87
|
// マスタデータシートを取得
|
88
88
|
|
89
|
-
var datasheet = SpreadsheetApp.openById('
|
89
|
+
var datasheet = SpreadsheetApp.openById('スプレッドシートID'').getSheetByName('マスタ');
|
90
90
|
|
91
91
|
// B列2行目のデータからB列の最終行までを取得
|
92
92
|
|
7
コードを省略しすぎたため、再記述させていただきました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,71 +34,113 @@
|
|
34
34
|
|
35
35
|
function doGet() {
|
36
36
|
|
37
|
-
|
37
|
+
return HtmlService.createTemplateFromFile('index')
|
38
|
-
|
38
|
+
|
39
|
-
|
39
|
+
.evaluate()
|
40
|
-
|
40
|
+
|
41
|
-
|
41
|
+
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
|
42
|
-
|
42
|
+
|
43
|
-
|
43
|
+
.addMetaTag('viewport', 'width=device-width, initial-scale=1')
|
44
|
-
|
44
|
+
|
45
|
-
|
45
|
+
.setTitle('gas入力フォームサンプル');
|
46
|
-
|
46
|
+
|
47
|
-
}
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
function registerSSByFormData(data) {
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
Logger.log("data = %s", data);
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
var datasheet = SpreadsheetApp.openById('スプレッドシートID').getSheetByName('シート1');
|
60
|
+
|
61
|
+
var now = new Date();
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
var i = datasheet.getLastRow() + 1;
|
66
|
+
|
67
|
+
datasheet.getRange(i, 11).setValue(data[11]);
|
68
|
+
|
69
|
+
datasheet.getRange(i, 12).setValue(Utilities.formatDate(now, 'Asia/Tokyo', 'yyyy/MM/dd HH:mm:ss'));
|
70
|
+
|
71
|
+
result = true;
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
return {data: true};
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
|
48
80
|
|
49
81
|
function getSelectListFromMasterSS() {
|
50
82
|
|
51
|
-
|
83
|
+
var selectList = [];
|
52
|
-
|
53
|
-
|
54
|
-
|
84
|
+
|
85
|
+
|
86
|
+
|
55
|
-
|
87
|
+
// マスタデータシートを取得
|
56
|
-
|
88
|
+
|
57
|
-
|
89
|
+
var datasheet = SpreadsheetApp.openById('15W5ZkhffV7rCyUZJSugBuNpVt2s98RW-eLDw0WgOeW4').getSheetByName('マスタ');
|
58
|
-
|
90
|
+
|
59
|
-
|
91
|
+
// B列2行目のデータからB列の最終行までを取得
|
60
|
-
|
92
|
+
|
61
|
-
|
93
|
+
var lastRow = datasheet.getRange("A:A").getValues().filter(String).length - 1;
|
62
|
-
|
94
|
+
|
63
|
-
|
95
|
+
//Logger.log("lastRow = %s", lastRow);
|
64
|
-
|
96
|
+
|
65
|
-
|
97
|
+
// B列2行目のデータからB列の最終行までを1列だけ取得
|
66
|
-
|
98
|
+
|
67
|
-
|
99
|
+
selectList = datasheet.getRange(2, 1, lastRow, 1).getValues();
|
68
|
-
|
100
|
+
|
69
|
-
|
101
|
+
//Logger.log("selectList = %s", selectList);
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
102
|
+
|
74
|
-
|
103
|
+
|
104
|
+
|
75
|
-
|
105
|
+
return {data: selectList};
|
76
|
-
|
77
|
-
|
106
|
+
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}
|
107
|
+
}
|
82
|
-
|
83
|
-
|
108
|
+
|
84
|
-
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
85
|
-
function
|
113
|
+
function Test(text) {
|
114
|
+
|
86
|
-
|
115
|
+
// マスタデータシートを取得
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
var datasheet = SpreadsheetApp.openById('スプレッドシートID').getSheetByName('マスタ');
|
122
|
+
|
87
|
-
|
123
|
+
var range = datasheet.getRange("A:A").getValues();
|
88
124
|
|
89
125
|
var lastRow = range.filter(String).length;
|
90
126
|
|
127
|
+
|
128
|
+
|
91
|
-
var loginData = sheet.getRange(2, 1, lastRow, 3).getValues(); //2~lastRow行目、3列分を二次元配列として取得
|
129
|
+
var loginData = datasheet.getRange(2, 1, lastRow, 3).getValues(); //2~lastRow行目、3列分を二次元配列として取得
|
130
|
+
|
131
|
+
|
92
132
|
|
93
133
|
loginData = loginData.filter(function(v) {
|
94
134
|
|
95
|
-
return v[0] ==
|
135
|
+
return v[0] == text;
|
96
|
-
|
136
|
+
|
97
|
-
});
|
137
|
+
}); //入力店コードデータのみ抽出
|
98
|
-
|
138
|
+
|
139
|
+
|
140
|
+
|
99
|
-
|
141
|
+
Logger.log(loginData)
|
100
|
-
|
142
|
+
|
101
|
-
|
143
|
+
//↑ここのログに出力された値(v[1]のみ)をHTML表示したいです
|
102
144
|
|
103
145
|
|
104
146
|
|
@@ -110,69 +152,273 @@
|
|
110
152
|
|
111
153
|
```
|
112
154
|
|
155
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
156
|
+
|
157
|
+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
158
|
+
|
159
|
+
<script src="https://use.fontawesome.com/7bcbed1321.js"></script>
|
160
|
+
|
161
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
|
162
|
+
|
163
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.1/js/bootstrap-select.min.js"></script>
|
164
|
+
|
165
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.8/validator.min.js"></script>
|
166
|
+
|
167
|
+
<script>
|
168
|
+
|
169
|
+
/**
|
170
|
+
|
171
|
+
コード.jsのgetSelectListFromSS()を読んで、スプレッドシートのデータをもとに、セレクトボックスを構築する
|
172
|
+
|
173
|
+
*/
|
174
|
+
|
113
175
|
function getSelectList() {
|
114
176
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
}
|
177
|
+
try {
|
178
|
+
|
179
|
+
google.script.run
|
180
|
+
|
181
|
+
.withSuccessHandler(function(result) {
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
console.log("result", result);
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
var select = document.getElementById('select_id3');
|
190
|
+
|
191
|
+
var option = document.createElement('option');
|
192
|
+
|
193
|
+
option.setAttribute('value', '');
|
194
|
+
|
195
|
+
option.setAttribute('selected', true);
|
196
|
+
|
197
|
+
option.innerHTML = '未選択';
|
198
|
+
|
199
|
+
select.appendChild(option);
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
for (var i = 0; i < result.data.length; i++) {
|
204
|
+
|
205
|
+
option = document.createElement('option');
|
206
|
+
|
207
|
+
option.setAttribute('value', i + 1);
|
208
|
+
|
209
|
+
option.innerHTML = result.data[i];
|
210
|
+
|
211
|
+
select.appendChild(option);
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
})
|
220
|
+
|
221
|
+
.withFailureHandler(function(result) {
|
222
|
+
|
223
|
+
toastr.error('リストの取得に失敗しました。', result);
|
224
|
+
|
225
|
+
})
|
226
|
+
|
227
|
+
.getSelectListFromMasterSS();
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
} catch (e) {
|
232
|
+
|
233
|
+
toastr.error(e);
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
/**
|
242
|
+
|
243
|
+
コード.jsのregisterSSByFormData()を呼んで、フォームの内容をスプレッドシートに登録する
|
244
|
+
|
245
|
+
*/
|
246
|
+
|
247
|
+
function sendData() {
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
try {
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
processing(true);
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
var elemntIFrame = window.parent.document.getElementById('userHtmlFrame');
|
260
|
+
|
261
|
+
elemntIFrame.setAttribute('scrolling', 'no');
|
262
|
+
|
263
|
+
elemntIFrame.setAttribute('frameborder', '0');
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
var data = [];
|
268
|
+
|
269
|
+
data[0] = 'dummy';
|
270
|
+
|
271
|
+
data[11] = document.getElementById('select_id3').options[document.getElementById('select_id3').selectedIndex].text;
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
console.log("data", data);
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
google.script.run
|
282
|
+
|
283
|
+
.withSuccessHandler(function(result) {
|
284
|
+
|
285
|
+
processing(false);
|
286
|
+
|
287
|
+
if (result.data) {
|
288
|
+
|
289
|
+
toastr.info('送信完了');
|
290
|
+
|
291
|
+
} else {
|
292
|
+
|
293
|
+
toastr.error('送信失敗しました');
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
})
|
298
|
+
|
299
|
+
.withFailureHandler(function(result) {
|
300
|
+
|
301
|
+
processing(false);
|
302
|
+
|
303
|
+
toastr.error('データ送信に失敗しました。', result);
|
304
|
+
|
305
|
+
})
|
306
|
+
|
307
|
+
.registerSSByFormData(data);
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
} catch (e) {
|
312
|
+
|
313
|
+
processing(false);
|
314
|
+
|
315
|
+
toastr.error(e);
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
//ここでHTMLでセレクトした値をGASへ送信
|
326
|
+
|
327
|
+
function outputSelectedValueAndText(obj)
|
328
|
+
|
329
|
+
{
|
330
|
+
|
331
|
+
/*
|
332
|
+
|
333
|
+
* obj は select タグであり、selectedIndex プロパティには
|
334
|
+
|
335
|
+
* 変更後の選択項目のインデックスが格納されています
|
336
|
+
|
337
|
+
*/
|
338
|
+
|
339
|
+
var idx = obj.selectedIndex;
|
340
|
+
|
341
|
+
var text = obj.options[idx].text; // 表示テキスト
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
// 値をコンソールに出力 (ここで「コード.gs 」 Testイベントへ)
|
346
|
+
|
347
|
+
google.script.run.Test(text);
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
// 処理中アイコン表示・非表示
|
358
|
+
|
359
|
+
function processing(processing) {
|
360
|
+
|
361
|
+
if (processing) {
|
362
|
+
|
363
|
+
document.getElementById('processing').style.visibility = "visible";
|
364
|
+
|
365
|
+
document.getElementById('send_button').setAttribute("disabled", true);
|
366
|
+
|
367
|
+
} else {
|
368
|
+
|
369
|
+
document.getElementById('processing').style.visibility = "hidden";
|
370
|
+
|
371
|
+
document.getElementById('send_button').removeAttribute("disabled");
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
}
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
// ロード完了後の処理
|
380
|
+
|
381
|
+
$(function() {
|
382
|
+
|
383
|
+
// トースト通知の位置指定
|
384
|
+
|
385
|
+
toastr.options.positionClass = "toast-bottom-left";
|
386
|
+
|
387
|
+
// バリデーションチェック有効化
|
388
|
+
|
389
|
+
$('#myForm').validator();
|
390
|
+
|
391
|
+
// 処理中アイコン非表示
|
392
|
+
|
393
|
+
processing(false);
|
394
|
+
|
395
|
+
// セレクトボックスのリストを動的に取得する
|
396
|
+
|
397
|
+
getSelectList();
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
// submit時のイベント登録
|
402
|
+
|
403
|
+
$('#myForm').validator().on('submit', function(e) {
|
404
|
+
|
405
|
+
if (document.getElementById('send_button').className.indexOf("disabled") != -1) {
|
406
|
+
|
407
|
+
// submit用のボタンのスタイルにdisabledが設定されていればバリデーションエラー
|
408
|
+
|
409
|
+
} else {
|
410
|
+
|
411
|
+
// バリデーションエラーでなければ送信
|
412
|
+
|
413
|
+
sendData();
|
414
|
+
|
415
|
+
}
|
416
|
+
|
417
|
+
})
|
418
|
+
|
419
|
+
});
|
420
|
+
|
421
|
+
</script>
|
176
422
|
|
177
423
|
|
178
424
|
|
@@ -186,81 +432,87 @@
|
|
186
432
|
|
187
433
|
<html lang="ja">
|
188
434
|
|
189
|
-
|
190
|
-
|
191
435
|
<head>
|
192
436
|
|
193
|
-
|
437
|
+
<meta charset="utf-8">
|
194
|
-
|
438
|
+
|
195
|
-
|
439
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
196
|
-
|
440
|
+
|
197
|
-
|
441
|
+
<?!= HtmlService.createHtmlOutputFromFile('stylesheet').getContent(); ?>
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
<!--クライアントスクリプト-->
|
202
|
-
|
203
|
-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
|
204
|
-
|
205
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
206
|
-
|
207
|
-
<script>
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
function dispLoginData(loginData) { // スプレッドシートから取得した情報を元にテーブルを構成
|
212
|
-
|
213
|
-
var td = '';
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
var v = loginData[i];
|
218
|
-
|
219
|
-
td = v[3]
|
220
|
-
|
221
|
-
}
|
222
|
-
|
223
|
-
$('#loginTr').html(td);
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
}
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
</script>
|
232
|
-
|
233
|
-
|
234
442
|
|
235
443
|
</head>
|
236
444
|
|
237
|
-
|
445
|
+
<body>
|
446
|
+
|
447
|
+
|
448
|
+
|
238
|
-
|
449
|
+
<nav class="navbar navbar-inverse">
|
450
|
+
|
451
|
+
<div class="navbar-header"><a class="navbar-brand" href="#">入力フォーム</a></div>
|
452
|
+
|
453
|
+
</nav>
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
<div class="container">
|
458
|
+
|
239
|
-
|
459
|
+
<form class="form-horizontal" id="myForm" name="myForm" onsubmit="return false;">
|
240
|
-
|
460
|
+
|
241
|
-
|
461
|
+
<div class="form-group">
|
242
|
-
|
462
|
+
|
243
|
-
|
463
|
+
<label class="control-label col-xs-3">セレクトボックス(動的)</label>
|
244
|
-
|
464
|
+
|
245
|
-
|
465
|
+
<div class="col-xs-9">
|
246
|
-
|
466
|
+
|
247
|
-
|
467
|
+
<select class="form-control" id="select_id3" name="select_id3" onchange="outputSelectedValueAndText(this);"></select>
|
468
|
+
|
469
|
+
|
470
|
+
|
248
|
-
|
471
|
+
<!--上記セレクトボックスにて選択時javascript.hymlのoutputSelectedValueAndTextイベントへ-->
|
472
|
+
|
473
|
+
|
474
|
+
|
249
|
-
|
475
|
+
<div class="help-block with-errors"></div>
|
250
|
-
|
476
|
+
|
251
|
-
|
477
|
+
</div>
|
252
|
-
|
478
|
+
|
253
|
-
|
479
|
+
</div>
|
480
|
+
|
481
|
+
|
482
|
+
|
254
|
-
|
483
|
+
<!--このあたりに「コード.gs」 function Test(text)のloginData(v[1])の値を表示したいです。-->
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
|
490
|
+
|
255
|
-
|
491
|
+
<div class="form-group">
|
492
|
+
|
256
|
-
|
493
|
+
<div class="col-xs-offset-3 col-xs-9">
|
494
|
+
|
495
|
+
<button id="send_button" type="submit" class="btn btn-primary btn-large">
|
496
|
+
|
497
|
+
<i class="fa fa-send fa-lg"></i>送信
|
498
|
+
|
499
|
+
</button>
|
500
|
+
|
501
|
+
</div>
|
502
|
+
|
503
|
+
</div>
|
504
|
+
|
257
|
-
|
505
|
+
</form>
|
258
|
-
|
506
|
+
|
259
|
-
|
507
|
+
<i id="processing" class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
|
260
|
-
|
508
|
+
|
261
|
-
|
509
|
+
</div>
|
262
|
-
|
510
|
+
|
263
|
-
|
511
|
+
<?!= HtmlService.createHtmlOutputFromFile('javascript').getContent(); ?>
|
512
|
+
|
513
|
+
</body>
|
514
|
+
|
515
|
+
</html>
|
264
516
|
|
265
517
|
|
266
518
|
|
6
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -252,6 +252,8 @@
|
|
252
252
|
|
253
253
|
</div>
|
254
254
|
|
255
|
+
<tbody id="loginTr">
|
256
|
+
|
255
257
|
</form>
|
256
258
|
|
257
259
|
<i id="processing" class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
|
5
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -202,7 +202,9 @@
|
|
202
202
|
|
203
203
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
|
204
204
|
|
205
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
|
205
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
206
|
+
|
207
|
+
<script>
|
206
208
|
|
207
209
|
|
208
210
|
|
@@ -234,36 +236,32 @@
|
|
234
236
|
|
235
237
|
|
236
238
|
|
237
|
-
<
|
239
|
+
<form class="form-horizontal" id="myForm" onsubmit="return false;" autocomplete="off">
|
238
|
-
|
240
|
+
|
239
|
-
<div class="form-group">
|
241
|
+
<div class="form-group">
|
240
|
-
|
242
|
+
|
241
|
-
<label class="control-label col-xs-3">(商品コード)商品名</label>
|
243
|
+
<label class="control-label col-xs-3">(商品コード)商品名</label>
|
242
|
-
|
244
|
+
|
243
|
-
<div class="col-xs-9">
|
245
|
+
<div class="col-xs-9">
|
244
|
-
|
246
|
+
|
245
|
-
<select class="form-control" id="select_id3" name="select_id3"
|
247
|
+
<select class="form-control" id="select_id3" name="select_id3" onChange="google.script.run.kakunin(this.value)"/required ></select>
|
246
|
-
|
248
|
+
|
247
|
-
<div class="help-block with-errors"></div>
|
249
|
+
<div class="help-block with-errors"></div>
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
250
|
+
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
</div>
|
251
|
+
</div>
|
252
|
+
|
253
|
+
</div>
|
254
|
+
|
255
|
+
</form>
|
256
|
+
|
257
|
+
<i id="processing" class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
|
256
258
|
|
257
259
|
</div>
|
258
260
|
|
259
|
-
<?!= HtmlService.createHtmlOutputFromFile('javascript').getContent(); ?>
|
261
|
+
<?!= HtmlService.createHtmlOutputFromFile('javascript').getContent(); ?>
|
260
|
-
|
261
|
-
|
262
|
+
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
263
|
+
|
266
|
-
|
267
|
-
|
268
|
-
|
264
|
+
|
265
|
+
|
266
|
+
|
269
|
-
```
|
267
|
+
```
|
4
不足箇所の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -256,7 +256,7 @@
|
|
256
256
|
|
257
257
|
</div>
|
258
258
|
|
259
|
-
|
259
|
+
<?!= HtmlService.createHtmlOutputFromFile('javascript').getContent(); ?>
|
260
260
|
|
261
261
|
</body>
|
262
262
|
|
3
余分箇所の削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -94,7 +94,7 @@
|
|
94
94
|
|
95
95
|
return v[0] == key;
|
96
96
|
|
97
|
-
});
|
97
|
+
});
|
98
98
|
|
99
99
|
Logger.log(loginData)
|
100
100
|
|
2
初心者マークつけ忘れ
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -242,7 +242,7 @@
|
|
242
242
|
|
243
243
|
<div class="col-xs-9">
|
244
244
|
|
245
|
-
<select class="form-control" id="select_id3" name="select_id3" "google.script.run.withSuccessHandler(dispLoginData).getLoginData(this.value)" /required ></select>
|
245
|
+
<select class="form-control" id="select_id3" name="select_id3" onchange="google.script.run.withSuccessHandler(dispLoginData).getLoginData(this.value)" /required ></select>
|
246
246
|
|
247
247
|
<div class="help-block with-errors"></div>
|
248
248
|
|