質問編集履歴
6
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
```html
|
15
15
|
<body>
|
16
16
|
<div class="container">
|
17
|
-
<form class="form-horizontal" id="resev-form" action="https://script.google.com/
|
17
|
+
<form class="form-horizontal" id="resev-form" action="https://script.google.com/・・・/exec"
|
18
18
|
method="post" target="_blank">
|
19
19
|
|
20
20
|
<div class="form-group">
|
5
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -57,81 +57,4 @@
|
|
57
57
|
|
58
58
|
|
59
59
|
|
60
|
-
何度も申し訳ありません。
|
61
|
-
どうしてもaction指定でどうにもできなかったので、google.script.runでやってみました。
|
62
|
-
するとpostに入ることができ、スプレッドシートの記入は確認できました。
|
63
|
-
|
64
|
-
あとは画面がthanks.htmlに飛べばよいのですが、まだできません。
|
65
|
-
進みが出たので確認だけでもお願いいたします。
|
66
|
-
|
67
|
-
```html
|
68
|
-
<body>
|
69
|
-
<div class="container">
|
70
|
-
<form class="form-horizontal"
|
71
|
-
onsubmit="handleFormSubmit();return false;"
|
72
|
-
method="post">
|
73
|
-
|
74
|
-
<div class="form-group">
|
75
|
-
<label class="control-label col-xs-3" for="input-id1">名前</label>
|
76
|
-
<input type="text" class="form-control" id="input_id1" name="name">
|
77
|
-
<div class="help-block with-errors"></div>
|
78
|
-
</div><!--form-group-->
|
79
|
-
|
80
|
-
<div class="form-group">
|
81
|
-
<label class="control-label" for="input-id3">電話番号<span class="asta">*</span></label>
|
82
|
-
<input type="tel" class="form-control" id="input-id3" name="tel" required>
|
83
|
-
<div class="help-block with-errors"></div>
|
84
|
-
</div><!--form-group-->
|
85
|
-
|
86
|
-
<div class="form-group">
|
87
|
-
<button type="submit" value="送信">
|
88
|
-
送信する
|
89
|
-
</button>
|
90
|
-
|
91
|
-
</div>
|
92
|
-
</form>
|
93
|
-
</div>
|
94
|
-
<script>
|
95
|
-
function handleFormSubmit(){
|
96
|
-
var ref= confirm("この内容で送信してもよろしいですか?");
|
97
|
-
if(ref){
|
98
|
-
var data=[];
|
99
|
-
data[0]=document.getElementById('input_id1').value;
|
100
|
-
data[1]=document.getElementById('input-id3').value
|
101
|
-
console.log("data", data);
|
102
|
-
|
103
|
-
|
104
|
-
google.script.run.withSuccessHandler(reload).doPost(data);
|
105
|
-
}
|
106
|
-
}
|
107
|
-
function reload(e) {
|
108
|
-
window.location.href = "<?!= ScriptApp.getService().getUrl(); ?>?page=thanks";
|
109
|
-
}
|
110
|
-
</script>
|
111
|
-
```
|
112
|
-
|
113
|
-
```gas
|
114
|
-
function doPost(e){
|
115
|
-
|
116
|
-
var name = e.name;
|
117
|
-
var tel = e.tel;
|
118
|
-
Logger.log(e.name);
|
119
|
-
var sheet = SpreadsheetApp.openById("スプレッドシートのID").getSheetByName("sheet1");
|
120
|
-
var arrData=sheet.getDataRange().getValues();
|
121
|
-
//データ取得
|
122
|
-
|
123
|
-
var now = new Date()
|
124
|
-
var status= "受付";
|
125
|
-
var array=[status, now,name,tel];
|
126
|
-
var rows = arrData.length;
|
127
|
-
var cols = arrData[0].length;
|
128
|
-
sheet.getRange(1,1,rows,cols).setValues(arrData);
|
129
|
-
|
60
|
+
まだ色々試していますがうまくいきません。4/4
|
130
|
-
|
131
|
-
↓ここで止まっています。createtemplateformfile()ではエラーになりました。
|
132
|
-
var temp = HtmlService.createHtmlOutputFromFile('thanks');
|
133
|
-
temp.data = name;
|
134
|
-
return temp.evaluate();
|
135
|
-
}
|
136
|
-
|
137
|
-
```
|
4
ついか
title
CHANGED
File without changes
|
body
CHANGED
@@ -53,4 +53,85 @@
|
|
53
53
|
}
|
54
54
|
↓でリターンを試みたりもしましたが同じ結果です、ポストに入りません。
|
55
55
|
return HtmlService.createHtmlOutputFromFile("thanks");
|
56
|
+
```
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
何度も申し訳ありません。
|
61
|
+
どうしてもaction指定でどうにもできなかったので、google.script.runでやってみました。
|
62
|
+
するとpostに入ることができ、スプレッドシートの記入は確認できました。
|
63
|
+
|
64
|
+
あとは画面がthanks.htmlに飛べばよいのですが、まだできません。
|
65
|
+
進みが出たので確認だけでもお願いいたします。
|
66
|
+
|
67
|
+
```html
|
68
|
+
<body>
|
69
|
+
<div class="container">
|
70
|
+
<form class="form-horizontal"
|
71
|
+
onsubmit="handleFormSubmit();return false;"
|
72
|
+
method="post">
|
73
|
+
|
74
|
+
<div class="form-group">
|
75
|
+
<label class="control-label col-xs-3" for="input-id1">名前</label>
|
76
|
+
<input type="text" class="form-control" id="input_id1" name="name">
|
77
|
+
<div class="help-block with-errors"></div>
|
78
|
+
</div><!--form-group-->
|
79
|
+
|
80
|
+
<div class="form-group">
|
81
|
+
<label class="control-label" for="input-id3">電話番号<span class="asta">*</span></label>
|
82
|
+
<input type="tel" class="form-control" id="input-id3" name="tel" required>
|
83
|
+
<div class="help-block with-errors"></div>
|
84
|
+
</div><!--form-group-->
|
85
|
+
|
86
|
+
<div class="form-group">
|
87
|
+
<button type="submit" value="送信">
|
88
|
+
送信する
|
89
|
+
</button>
|
90
|
+
|
91
|
+
</div>
|
92
|
+
</form>
|
93
|
+
</div>
|
94
|
+
<script>
|
95
|
+
function handleFormSubmit(){
|
96
|
+
var ref= confirm("この内容で送信してもよろしいですか?");
|
97
|
+
if(ref){
|
98
|
+
var data=[];
|
99
|
+
data[0]=document.getElementById('input_id1').value;
|
100
|
+
data[1]=document.getElementById('input-id3').value
|
101
|
+
console.log("data", data);
|
102
|
+
|
103
|
+
|
104
|
+
google.script.run.withSuccessHandler(reload).doPost(data);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
function reload(e) {
|
108
|
+
window.location.href = "<?!= ScriptApp.getService().getUrl(); ?>?page=thanks";
|
109
|
+
}
|
110
|
+
</script>
|
111
|
+
```
|
112
|
+
|
113
|
+
```gas
|
114
|
+
function doPost(e){
|
115
|
+
|
116
|
+
var name = e.name;
|
117
|
+
var tel = e.tel;
|
118
|
+
Logger.log(e.name);
|
119
|
+
var sheet = SpreadsheetApp.openById("スプレッドシートのID").getSheetByName("sheet1");
|
120
|
+
var arrData=sheet.getDataRange().getValues();
|
121
|
+
//データ取得
|
122
|
+
|
123
|
+
var now = new Date()
|
124
|
+
var status= "受付";
|
125
|
+
var array=[status, now,name,tel];
|
126
|
+
var rows = arrData.length;
|
127
|
+
var cols = arrData[0].length;
|
128
|
+
sheet.getRange(1,1,rows,cols).setValues(arrData);
|
129
|
+
sheet.appendRow(array);
|
130
|
+
|
131
|
+
↓ここで止まっています。createtemplateformfile()ではエラーになりました。
|
132
|
+
var temp = HtmlService.createHtmlOutputFromFile('thanks');
|
133
|
+
temp.data = name;
|
134
|
+
return temp.evaluate();
|
135
|
+
}
|
136
|
+
|
56
137
|
```
|
3
不要分を削除
title
CHANGED
File without changes
|
body
CHANGED
@@ -53,69 +53,4 @@
|
|
53
53
|
}
|
54
54
|
↓でリターンを試みたりもしましたが同じ結果です、ポストに入りません。
|
55
55
|
return HtmlService.createHtmlOutputFromFile("thanks");
|
56
|
-
}
|
57
|
-
|
58
|
-
```
|
59
|
-
|
60
|
-
|
61
|
-
成果物1
|
62
|
-
```html
|
63
|
-
<body>
|
64
|
-
<div class="container">
|
65
|
-
<form class="form-horizontal"
|
66
|
-
action="https://script.google.com/macros/s/AKfycbykEpB34c0c7yjXqXua2IWguy3lwtsoI8CG0XJwRhQ-LsDXkPhc/exec"
|
67
|
-
method="post">
|
68
|
-
|
69
|
-
<div class="form-group">
|
70
|
-
<label class="control-label col-xs-3" for="input-id1">名前</label>
|
71
|
-
<input type="text" class="form-control" id="input_id1" name="name">
|
72
|
-
<div class="help-block with-errors"></div>
|
73
|
-
</div><!--form-group-->
|
74
|
-
|
75
|
-
<div class="form-group">
|
76
|
-
<label class="control-label" for="input-id3">電話番号<span class="asta">*</span></label>
|
77
|
-
<input type="tel" class="form-control" id="input-id3" name="tel" required>
|
78
|
-
<div class="help-block with-errors"></div>
|
79
|
-
</div><!--form-group-->
|
80
|
-
|
81
|
-
<div class="form-group">
|
82
|
-
<button type="submit" value="送信">
|
83
|
-
送信する
|
84
|
-
</button>
|
85
|
-
|
86
|
-
</div>
|
87
|
-
|
88
|
-
</form>
|
89
|
-
</div>
|
90
|
-
```
|
91
|
-
```html
|
92
|
-
別プロジェクトのHTML thanks.html
|
93
|
-
<body>
|
94
|
-
<p>これが本物です</p>
|
95
|
-
|
96
|
-
<script>
|
97
|
-
var inputdata = String("<?= data ?>");
|
98
|
-
</script>
|
99
|
-
</body>
|
100
|
-
</html>
|
101
|
-
|
102
|
-
```
|
103
|
-
```gas
|
104
|
-
どちらもindex.html側のgasに記載
|
105
|
-
function doGet(){
|
106
|
-
var HtmlOutput = HtmlService.createHtmlOutputFromFile('html');
|
107
|
-
return HtmlOutput;
|
108
|
-
}
|
109
|
-
|
110
|
-
|
111
|
-
function doPost(e){
|
112
|
-
|
113
|
-
var name = e.parameter.name;
|
114
|
-
var tel = e.parameter.tel;
|
115
|
-
Logger.log(e.parameter.name);
|
116
|
-
var temp = HtmlService.createHtmlOutputFromFile('thanks');
|
117
|
-
temp.data = [name,tel]; ←data項目なしでも遷移はする。遷移先の画面でどう値を取得するべきかは詰めれていない。
|
118
|
-
return temp.evaluate();
|
119
|
-
}
|
120
|
-
|
121
56
|
```
|
2
一旦わかったことを更新
title
CHANGED
File without changes
|
body
CHANGED
@@ -55,4 +55,67 @@
|
|
55
55
|
return HtmlService.createHtmlOutputFromFile("thanks");
|
56
56
|
}
|
57
57
|
|
58
|
+
```
|
59
|
+
|
60
|
+
|
61
|
+
成果物1
|
62
|
+
```html
|
63
|
+
<body>
|
64
|
+
<div class="container">
|
65
|
+
<form class="form-horizontal"
|
66
|
+
action="https://script.google.com/macros/s/AKfycbykEpB34c0c7yjXqXua2IWguy3lwtsoI8CG0XJwRhQ-LsDXkPhc/exec"
|
67
|
+
method="post">
|
68
|
+
|
69
|
+
<div class="form-group">
|
70
|
+
<label class="control-label col-xs-3" for="input-id1">名前</label>
|
71
|
+
<input type="text" class="form-control" id="input_id1" name="name">
|
72
|
+
<div class="help-block with-errors"></div>
|
73
|
+
</div><!--form-group-->
|
74
|
+
|
75
|
+
<div class="form-group">
|
76
|
+
<label class="control-label" for="input-id3">電話番号<span class="asta">*</span></label>
|
77
|
+
<input type="tel" class="form-control" id="input-id3" name="tel" required>
|
78
|
+
<div class="help-block with-errors"></div>
|
79
|
+
</div><!--form-group-->
|
80
|
+
|
81
|
+
<div class="form-group">
|
82
|
+
<button type="submit" value="送信">
|
83
|
+
送信する
|
84
|
+
</button>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
</form>
|
89
|
+
</div>
|
90
|
+
```
|
91
|
+
```html
|
92
|
+
別プロジェクトのHTML thanks.html
|
93
|
+
<body>
|
94
|
+
<p>これが本物です</p>
|
95
|
+
|
96
|
+
<script>
|
97
|
+
var inputdata = String("<?= data ?>");
|
98
|
+
</script>
|
99
|
+
</body>
|
100
|
+
</html>
|
101
|
+
|
102
|
+
```
|
103
|
+
```gas
|
104
|
+
どちらもindex.html側のgasに記載
|
105
|
+
function doGet(){
|
106
|
+
var HtmlOutput = HtmlService.createHtmlOutputFromFile('html');
|
107
|
+
return HtmlOutput;
|
108
|
+
}
|
109
|
+
|
110
|
+
|
111
|
+
function doPost(e){
|
112
|
+
|
113
|
+
var name = e.parameter.name;
|
114
|
+
var tel = e.parameter.tel;
|
115
|
+
Logger.log(e.parameter.name);
|
116
|
+
var temp = HtmlService.createHtmlOutputFromFile('thanks');
|
117
|
+
temp.data = [name,tel]; ←data項目なしでも遷移はする。遷移先の画面でどう値を取得するべきかは詰めれていない。
|
118
|
+
return temp.evaluate();
|
119
|
+
}
|
120
|
+
|
58
121
|
```
|
1
コードを追加しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,4 +8,51 @@
|
|
8
8
|
もうなんども調べているのですが、よくわからないので、聞いています。
|
9
9
|
ちなみにそのPostの中ではdoPost(e){}で受け取り、e.parameter.nameという形で取得しようとしていました。
|
10
10
|
|
11
|
-
わかる方いましたら、Postはどんな形で送信されているのか教えて欲しいです。
|
11
|
+
わかる方いましたら、Postはどんな形で送信されているのか教えて欲しいです。
|
12
|
+
|
13
|
+
追記
|
14
|
+
```html
|
15
|
+
<body>
|
16
|
+
<div class="container">
|
17
|
+
<form class="form-horizontal" id="resev-form" action="https://script.google.com/macros/s/AKfycbxK9ReLvepxhWH3GKCRyp6v_IVQqZM1yvIzL3kiXpz_CMI_U7U/exec"
|
18
|
+
method="post" target="_blank">
|
19
|
+
|
20
|
+
<div class="form-group">
|
21
|
+
<label class="control-label col-xs-3 col-la-3" for="input-id1">名前</label>
|
22
|
+
<div class="col-xs-3 col-la-3">
|
23
|
+
<input type="text" class="form-control" id="input_id1" name="name">
|
24
|
+
<div class="help-block with-errors"></div>
|
25
|
+
</div>
|
26
|
+
</div><!--form-group-->
|
27
|
+
|
28
|
+
<div class="form-group">
|
29
|
+
<div class="col-xs-offset-3 col-xs-9">
|
30
|
+
<button id="send_button" type="submit" class="btn btn-primary btn-block">
|
31
|
+
送信する
|
32
|
+
</button>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
</form>
|
37
|
+
</div>
|
38
|
+
</body>
|
39
|
+
```
|
40
|
+
|
41
|
+
```gs
|
42
|
+
function doGet(){
|
43
|
+
var HtmlOutput = HtmlService.createHtmlOutputFromFile('html');
|
44
|
+
return HtmlOutput;
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
function doPost(e){
|
49
|
+
|
50
|
+
var val = e.parameter.name;
|
51
|
+
Logger.log(e);
|
52
|
+
return ContentService.createTextOutput(e.parameter.name);
|
53
|
+
}
|
54
|
+
↓でリターンを試みたりもしましたが同じ結果です、ポストに入りません。
|
55
|
+
return HtmlService.createHtmlOutputFromFile("thanks");
|
56
|
+
}
|
57
|
+
|
58
|
+
```
|