質問編集履歴

6

修正

2019/04/04 10:21

投稿

mmtt234
mmtt234

スコア14

test CHANGED
File without changes
test CHANGED
@@ -30,7 +30,7 @@
30
30
 
31
31
  <div class="container">
32
32
 
33
- <form class="form-horizontal" id="resev-form" action="https://script.google.com/macros/s/AKfycbxK9ReLvepxhWH3GKCRyp6v_IVQqZM1yvIzL3kiXpz_CMI_U7U/exec"
33
+ <form class="form-horizontal" id="resev-form" action="https://script.google.com/・・・/exec"
34
34
 
35
35
  method="post" target="_blank">
36
36
 

5

修正

2019/04/04 10:21

投稿

mmtt234
mmtt234

スコア14

test CHANGED
File without changes
test CHANGED
@@ -116,158 +116,4 @@
116
116
 
117
117
 
118
118
 
119
- 何度も申し訳ありません。
120
-
121
- どうしてもaction指定でどうにもできなかったので、google.script.runでやってみました。
122
-
123
- するとpostに入ることができ、スプレッドシートの記入は確認できました。
124
-
125
-
126
-
127
- あとは画面がthanks.htmlに飛べばよいのですが、まだできません。
128
-
129
- 進みが出たので確認だけでもお願いいたします。
130
-
131
-
132
-
133
- ```html
134
-
135
- <body>
136
-
137
- <div class="container">
138
-
139
- <form class="form-horizontal" 
140
-
141
- onsubmit="handleFormSubmit();return false;"
142
-
143
- method="post">
144
-
145
-
146
-
147
- <div class="form-group">
148
-
149
- <label class="control-label col-xs-3" for="input-id1">名前</label>
150
-
151
- <input type="text" class="form-control" id="input_id1" name="name">
152
-
153
- <div class="help-block with-errors"></div>
154
-
155
- </div><!--form-group-->
156
-
157
-
158
-
159
- <div class="form-group">
160
-
161
- <label class="control-label" for="input-id3">電話番号<span class="asta">*</span></label>
162
-
163
- <input type="tel" class="form-control" id="input-id3" name="tel" required>
164
-
165
- <div class="help-block with-errors"></div>
166
-
167
- </div><!--form-group-->
168
-
169
-
170
-
171
- <div class="form-group">
172
-
173
- <button type="submit" value="送信">
174
-
175
- 送信する
176
-
177
- </button>
178
-
179
-
180
-
181
- </div>
182
-
183
- </form>
184
-
185
- </div>
186
-
187
- <script>
188
-
189
- function handleFormSubmit(){
190
-
191
- var ref= confirm("この内容で送信してもよろしいですか?");
192
-
193
- if(ref){
194
-
195
- var data=[];
196
-
197
- data[0]=document.getElementById('input_id1').value;
198
-
199
- data[1]=document.getElementById('input-id3').value
200
-
201
- console.log("data", data);
202
-
203
-
204
-
205
-
206
-
207
- google.script.run.withSuccessHandler(reload).doPost(data);
208
-
209
- }
210
-
211
- }
212
-
213
- function reload(e) {
214
-
215
- window.location.href = "<?!= ScriptApp.getService().getUrl(); ?>?page=thanks";
216
-
217
- }
218
-
219
- </script>
220
-
221
- ```
222
-
223
-
224
-
225
- ```gas
226
-
227
- function doPost(e){
228
-
229
-
230
-
231
- var name = e.name;
232
-
233
- var tel = e.tel;
234
-
235
- Logger.log(e.name);
236
-
237
- var sheet = SpreadsheetApp.openById("スプレッドシートのID").getSheetByName("sheet1");
238
-
239
- var arrData=sheet.getDataRange().getValues();
240
-
241
- //データ取得
242
-
243
-
244
-
245
- var now = new Date()
246
-
247
- var status= "受付";
248
-
249
- var array=[status, now,name,tel];
250
-
251
- var rows = arrData.length;
252
-
253
- var cols = arrData[0].length;
254
-
255
- sheet.getRange(1,1,rows,cols).setValues(arrData);
256
-
257
- sheet.appendRow(array);
119
+ まだ色々試していますがうまくいきません。4/4
258
-
259
-
260
-
261
-   ↓ここで止まっています。createtemplateformfile()ではエラーになりました。
262
-
263
- var temp = HtmlService.createHtmlOutputFromFile('thanks');
264
-
265
- temp.data = name;
266
-
267
- return temp.evaluate();
268
-
269
- }
270
-
271
-
272
-
273
- ```

4

ついか

2019/04/04 10:19

投稿

mmtt234
mmtt234

スコア14

test CHANGED
File without changes
test CHANGED
@@ -109,3 +109,165 @@
109
109
  return HtmlService.createHtmlOutputFromFile("thanks");
110
110
 
111
111
  ```
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+ 何度も申し訳ありません。
120
+
121
+ どうしてもaction指定でどうにもできなかったので、google.script.runでやってみました。
122
+
123
+ するとpostに入ることができ、スプレッドシートの記入は確認できました。
124
+
125
+
126
+
127
+ あとは画面がthanks.htmlに飛べばよいのですが、まだできません。
128
+
129
+ 進みが出たので確認だけでもお願いいたします。
130
+
131
+
132
+
133
+ ```html
134
+
135
+ <body>
136
+
137
+ <div class="container">
138
+
139
+ <form class="form-horizontal" 
140
+
141
+ onsubmit="handleFormSubmit();return false;"
142
+
143
+ method="post">
144
+
145
+
146
+
147
+ <div class="form-group">
148
+
149
+ <label class="control-label col-xs-3" for="input-id1">名前</label>
150
+
151
+ <input type="text" class="form-control" id="input_id1" name="name">
152
+
153
+ <div class="help-block with-errors"></div>
154
+
155
+ </div><!--form-group-->
156
+
157
+
158
+
159
+ <div class="form-group">
160
+
161
+ <label class="control-label" for="input-id3">電話番号<span class="asta">*</span></label>
162
+
163
+ <input type="tel" class="form-control" id="input-id3" name="tel" required>
164
+
165
+ <div class="help-block with-errors"></div>
166
+
167
+ </div><!--form-group-->
168
+
169
+
170
+
171
+ <div class="form-group">
172
+
173
+ <button type="submit" value="送信">
174
+
175
+ 送信する
176
+
177
+ </button>
178
+
179
+
180
+
181
+ </div>
182
+
183
+ </form>
184
+
185
+ </div>
186
+
187
+ <script>
188
+
189
+ function handleFormSubmit(){
190
+
191
+ var ref= confirm("この内容で送信してもよろしいですか?");
192
+
193
+ if(ref){
194
+
195
+ var data=[];
196
+
197
+ data[0]=document.getElementById('input_id1').value;
198
+
199
+ data[1]=document.getElementById('input-id3').value
200
+
201
+ console.log("data", data);
202
+
203
+
204
+
205
+
206
+
207
+ google.script.run.withSuccessHandler(reload).doPost(data);
208
+
209
+ }
210
+
211
+ }
212
+
213
+ function reload(e) {
214
+
215
+ window.location.href = "<?!= ScriptApp.getService().getUrl(); ?>?page=thanks";
216
+
217
+ }
218
+
219
+ </script>
220
+
221
+ ```
222
+
223
+
224
+
225
+ ```gas
226
+
227
+ function doPost(e){
228
+
229
+
230
+
231
+ var name = e.name;
232
+
233
+ var tel = e.tel;
234
+
235
+ Logger.log(e.name);
236
+
237
+ var sheet = SpreadsheetApp.openById("スプレッドシートのID").getSheetByName("sheet1");
238
+
239
+ var arrData=sheet.getDataRange().getValues();
240
+
241
+ //データ取得
242
+
243
+
244
+
245
+ var now = new Date()
246
+
247
+ var status= "受付";
248
+
249
+ var array=[status, now,name,tel];
250
+
251
+ var rows = arrData.length;
252
+
253
+ var cols = arrData[0].length;
254
+
255
+ sheet.getRange(1,1,rows,cols).setValues(arrData);
256
+
257
+ sheet.appendRow(array);
258
+
259
+
260
+
261
+   ↓ここで止まっています。createtemplateformfile()ではエラーになりました。
262
+
263
+ var temp = HtmlService.createHtmlOutputFromFile('thanks');
264
+
265
+ temp.data = name;
266
+
267
+ return temp.evaluate();
268
+
269
+ }
270
+
271
+
272
+
273
+ ```

3

不要分を削除

2019/04/02 08:48

投稿

mmtt234
mmtt234

スコア14

test CHANGED
File without changes
test CHANGED
@@ -108,134 +108,4 @@
108
108
 
109
109
  return HtmlService.createHtmlOutputFromFile("thanks");
110
110
 
111
- }
112
-
113
-
114
-
115
111
  ```
116
-
117
-
118
-
119
-
120
-
121
- 成果物1
122
-
123
- ```html
124
-
125
- <body>
126
-
127
- <div class="container">
128
-
129
- <form class="form-horizontal" 
130
-
131
- action="https://script.google.com/macros/s/AKfycbykEpB34c0c7yjXqXua2IWguy3lwtsoI8CG0XJwRhQ-LsDXkPhc/exec"
132
-
133
- method="post">
134
-
135
-
136
-
137
- <div class="form-group">
138
-
139
- <label class="control-label col-xs-3" for="input-id1">名前</label>
140
-
141
- <input type="text" class="form-control" id="input_id1" name="name">
142
-
143
- <div class="help-block with-errors"></div>
144
-
145
- </div><!--form-group-->
146
-
147
-
148
-
149
- <div class="form-group">
150
-
151
- <label class="control-label" for="input-id3">電話番号<span class="asta">*</span></label>
152
-
153
- <input type="tel" class="form-control" id="input-id3" name="tel" required>
154
-
155
- <div class="help-block with-errors"></div>
156
-
157
- </div><!--form-group-->
158
-
159
-
160
-
161
- <div class="form-group">
162
-
163
- <button type="submit" value="送信">
164
-
165
- 送信する
166
-
167
- </button>
168
-
169
-
170
-
171
- </div>
172
-
173
-
174
-
175
- </form>
176
-
177
- </div>
178
-
179
- ```
180
-
181
- ```html
182
-
183
- 別プロジェクトのHTML thanks.html
184
-
185
- <body>
186
-
187
- <p>これが本物です</p>
188
-
189
-
190
-
191
- <script>
192
-
193
- var inputdata = String("<?= data ?>");
194
-
195
- </script>
196
-
197
- </body>
198
-
199
- </html>
200
-
201
-
202
-
203
- ```
204
-
205
- ```gas
206
-
207
- どちらもindex.html側のgasに記載
208
-
209
- function doGet(){
210
-
211
- var HtmlOutput = HtmlService.createHtmlOutputFromFile('html');
212
-
213
- return HtmlOutput;
214
-
215
- }
216
-
217
-
218
-
219
-
220
-
221
- function doPost(e){
222
-
223
-
224
-
225
- var name = e.parameter.name;
226
-
227
- var tel = e.parameter.tel;
228
-
229
- Logger.log(e.parameter.name);
230
-
231
- var temp = HtmlService.createHtmlOutputFromFile('thanks');
232
-
233
- temp.data = [name,tel]; ←data項目なしでも遷移はする。遷移先の画面でどう値を取得するべきかは詰めれていない。
234
-
235
- return temp.evaluate();
236
-
237
- }
238
-
239
-
240
-
241
- ```

2

一旦わかったことを更新

2019/04/02 02:02

投稿

mmtt234
mmtt234

スコア14

test CHANGED
File without changes
test CHANGED
@@ -113,3 +113,129 @@
113
113
 
114
114
 
115
115
  ```
116
+
117
+
118
+
119
+
120
+
121
+ 成果物1
122
+
123
+ ```html
124
+
125
+ <body>
126
+
127
+ <div class="container">
128
+
129
+ <form class="form-horizontal" 
130
+
131
+ action="https://script.google.com/macros/s/AKfycbykEpB34c0c7yjXqXua2IWguy3lwtsoI8CG0XJwRhQ-LsDXkPhc/exec"
132
+
133
+ method="post">
134
+
135
+
136
+
137
+ <div class="form-group">
138
+
139
+ <label class="control-label col-xs-3" for="input-id1">名前</label>
140
+
141
+ <input type="text" class="form-control" id="input_id1" name="name">
142
+
143
+ <div class="help-block with-errors"></div>
144
+
145
+ </div><!--form-group-->
146
+
147
+
148
+
149
+ <div class="form-group">
150
+
151
+ <label class="control-label" for="input-id3">電話番号<span class="asta">*</span></label>
152
+
153
+ <input type="tel" class="form-control" id="input-id3" name="tel" required>
154
+
155
+ <div class="help-block with-errors"></div>
156
+
157
+ </div><!--form-group-->
158
+
159
+
160
+
161
+ <div class="form-group">
162
+
163
+ <button type="submit" value="送信">
164
+
165
+ 送信する
166
+
167
+ </button>
168
+
169
+
170
+
171
+ </div>
172
+
173
+
174
+
175
+ </form>
176
+
177
+ </div>
178
+
179
+ ```
180
+
181
+ ```html
182
+
183
+ 別プロジェクトのHTML thanks.html
184
+
185
+ <body>
186
+
187
+ <p>これが本物です</p>
188
+
189
+
190
+
191
+ <script>
192
+
193
+ var inputdata = String("<?= data ?>");
194
+
195
+ </script>
196
+
197
+ </body>
198
+
199
+ </html>
200
+
201
+
202
+
203
+ ```
204
+
205
+ ```gas
206
+
207
+ どちらもindex.html側のgasに記載
208
+
209
+ function doGet(){
210
+
211
+ var HtmlOutput = HtmlService.createHtmlOutputFromFile('html');
212
+
213
+ return HtmlOutput;
214
+
215
+ }
216
+
217
+
218
+
219
+
220
+
221
+ function doPost(e){
222
+
223
+
224
+
225
+ var name = e.parameter.name;
226
+
227
+ var tel = e.parameter.tel;
228
+
229
+ Logger.log(e.parameter.name);
230
+
231
+ var temp = HtmlService.createHtmlOutputFromFile('thanks');
232
+
233
+ temp.data = [name,tel]; ←data項目なしでも遷移はする。遷移先の画面でどう値を取得するべきかは詰めれていない。
234
+
235
+ return temp.evaluate();
236
+
237
+ }
238
+
239
+
240
+
241
+ ```

1

コードを追加しました。

2019/04/02 01:54

投稿

mmtt234
mmtt234

スコア14

test CHANGED
File without changes
test CHANGED
@@ -19,3 +19,97 @@
19
19
 
20
20
 
21
21
  わかる方いましたら、Postはどんな形で送信されているのか教えて欲しいです。
22
+
23
+
24
+
25
+ 追記
26
+
27
+ ```html
28
+
29
+ <body>
30
+
31
+ <div class="container">
32
+
33
+ <form class="form-horizontal" id="resev-form" action="https://script.google.com/macros/s/AKfycbxK9ReLvepxhWH3GKCRyp6v_IVQqZM1yvIzL3kiXpz_CMI_U7U/exec"
34
+
35
+ method="post" target="_blank">
36
+
37
+
38
+
39
+ <div class="form-group">
40
+
41
+ <label class="control-label col-xs-3 col-la-3" for="input-id1">名前</label>
42
+
43
+ <div class="col-xs-3 col-la-3">
44
+
45
+ <input type="text" class="form-control" id="input_id1" name="name">
46
+
47
+ <div class="help-block with-errors"></div>
48
+
49
+ </div>
50
+
51
+ </div><!--form-group-->
52
+
53
+
54
+
55
+ <div class="form-group">
56
+
57
+ <div class="col-xs-offset-3 col-xs-9">
58
+
59
+ <button id="send_button" type="submit" class="btn btn-primary btn-block">
60
+
61
+ 送信する
62
+
63
+ </button>
64
+
65
+ </div>
66
+
67
+ </div>
68
+
69
+
70
+
71
+ </form>
72
+
73
+ </div>
74
+
75
+ </body>
76
+
77
+ ```
78
+
79
+
80
+
81
+ ```gs
82
+
83
+ function doGet(){
84
+
85
+ var HtmlOutput = HtmlService.createHtmlOutputFromFile('html');
86
+
87
+ return HtmlOutput;
88
+
89
+ }
90
+
91
+
92
+
93
+
94
+
95
+ function doPost(e){
96
+
97
+
98
+
99
+ var val = e.parameter.name;
100
+
101
+ Logger.log(e);
102
+
103
+ return ContentService.createTextOutput(e.parameter.name);
104
+
105
+ }
106
+
107
+ ↓でリターンを試みたりもしましたが同じ結果です、ポストに入りません。
108
+
109
+ return HtmlService.createHtmlOutputFromFile("thanks");
110
+
111
+ }
112
+
113
+
114
+
115
+ ```