質問編集履歴

2

修正

2018/04/10 02:36

投稿

tomagurosu
tomagurosu

スコア37

test CHANGED
File without changes
test CHANGED
@@ -250,9 +250,7 @@
250
250
 
251
251
  $reqList = array_merge($reqList, $reqOutputItem);
252
252
 
253
- // $command = .....;
253
+ $command = ......;
254
-
255
- $command = "go run linkageTest.go";
256
254
 
257
255
  foreach($reqList as $index => $value) {
258
256
 

1

コード全文追加, 確認済み事項記述

2018/04/10 02:36

投稿

tomagurosu
tomagurosu

スコア37

test CHANGED
File without changes
test CHANGED
@@ -59,3 +59,273 @@
59
59
  記述箇所はbodyタグの直前になります。
60
60
 
61
61
  どなたかご教授お願いいたします
62
+
63
+
64
+
65
+ ```JavaScript
66
+
67
+ <!DOCTYPE html>
68
+
69
+ <html>
70
+
71
+ <head>
72
+
73
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
74
+
75
+ <title>beaconLog</title>
76
+
77
+ </head>
78
+
79
+
80
+
81
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
82
+
83
+ <script type="text/javascript">
84
+
85
+ $(function() {
86
+
87
+ $('#outputBtn').click(
88
+
89
+ function(){
90
+
91
+ setDownloadBox();
92
+
93
+ });
94
+
95
+ function setDownloadBox(){
96
+
97
+ $.ajax({
98
+
99
+ type:'POST',
100
+
101
+ url :'getCSV.php',
102
+
103
+ data:{key:'value'}
104
+
105
+ }).fail(function(){
106
+
107
+ alert('error');
108
+
109
+ }).done(function(buf){
110
+
111
+ result = JSON.parse(buf);
112
+
113
+ for(var value of result){
114
+
115
+ $('#downloadBox').append(`<a href="csv/`+ value +`" download="` + value + `">` + value + `</a><br>`);
116
+
117
+ }
118
+
119
+ });
120
+
121
+ }
122
+
123
+ })
124
+
125
+ </script>
126
+
127
+
128
+
129
+ <body>
130
+
131
+ <?php
132
+
133
+ $env = [.....];
134
+
135
+ $envSelectBox = "<select name=\"selectedEnv\">\n";
136
+
137
+ for ($i = 0; $i < count($env); $i++) {
138
+
139
+ $envSelectBox .= "\t<option value=\"{$env[$i]}\">{$env[$i]}</option>\n";
140
+
141
+ }
142
+
143
+ $envSelectBox .= "</select>\n";
144
+
145
+
146
+
147
+ date_default_timezone_set("Asia/Tokyo");
148
+
149
+ $defaultFirstDate = date("Y年m月d日H時", strtotime("-1 hour"))."0分0秒";
150
+
151
+ $defaultLastDate = date("Y年m月d日H時")."59分59秒";
152
+
153
+
154
+
155
+ $refineItemList = [.....];
156
+
157
+ $refineItemBox = "";
158
+
159
+ foreach ($refineItemList as $key => $value) {
160
+
161
+ $refineItemBox .= "{$value}<br>\n<input type=\"text\" name=\"{$key}\"><br>\n";
162
+
163
+
164
+
165
+ // 末尾のアンダーバーで初期値チェックを判断
166
+
167
+ $outPutItemList = [.....];
168
+
169
+ $outputItemBox = "";
170
+
171
+ $i = 1;
172
+
173
+ foreach($outPutItemList as $key => $value) {
174
+
175
+ $outputItemBox .= "<input type=\"checkbox\" name=\"outputItem[]\" value=\"{$key}\"";
176
+
177
+ $pattern = "/_/";
178
+
179
+
180
+
181
+ if(preg_match($pattern, $value)){
182
+
183
+ $result = preg_replace($pattern, "", $value);
184
+
185
+ $outputItemBox .= "checked >{$result}\n";
186
+
187
+ }
188
+
189
+ else{
190
+
191
+ $outputItemBox .= ">{$value}\n";
192
+
193
+ }
194
+
195
+
196
+
197
+ // 4項目ごとに改行
198
+
199
+ if($i % 4 == 0){$outputItemBox .= "<br>\n";}
200
+
201
+ $i ++;
202
+
203
+ }
204
+
205
+ ?>
206
+
207
+
208
+
209
+ <h2>入力項目</h2>
210
+
211
+
212
+
213
+ <form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post">
214
+
215
+
216
+
217
+ 環境<br>
218
+
219
+ <?php echo "{$envSelectBox}<br>";?>
220
+
221
+
222
+
223
+ From 年月日時分秒<br>
224
+
225
+ <input type="text" size="30" value=<?php echo $defaultFirstDate;?> name="FirstDate"><br>
226
+
227
+
228
+
229
+ To 年月日時分秒<br>
230
+
231
+ <input type="text" size="30" value=<?php echo $defaultLastDate;?> name="LastDate"><br>
232
+
233
+
234
+
235
+ <?php echo "<h2>絞り込み項目</h2>";
236
+
237
+ echo $refineItemBox;
238
+
239
+ echo "<input type=\"submit\" id=\"outputBtn\" value=\"出力\" />";
240
+
241
+ echo "<h2>出力項目</h2>";
242
+
243
+ echo $outputItemBox;
244
+
245
+
246
+
247
+ $reqList = [.....];
248
+
249
+ $reqOutputItem = $_POST["outputItem"];
250
+
251
+ $reqList = array_merge($reqList, $reqOutputItem);
252
+
253
+ // $command = .....;
254
+
255
+ $command = "go run linkageTest.go";
256
+
257
+ foreach($reqList as $index => $value) {
258
+
259
+ $command.= " \"{$value}\"";
260
+
261
+ }
262
+
263
+ exec($command);
264
+
265
+ ?>
266
+
267
+ <div id="downloadBox">
268
+
269
+ </div>
270
+
271
+
272
+
273
+ </form>
274
+
275
+
276
+
277
+ </body>
278
+
279
+
280
+
281
+ </html>
282
+
283
+
284
+
285
+ ```
286
+
287
+
288
+
289
+ 変数の内容は事情により省略していますがこれがソースコードの全文になります。
290
+
291
+ 下記コードのコメントアウト部分でそれぞれ処理の流れを追いましたが特に止まっている個所はなく処理が進んでいるようでした....
292
+
293
+ またbuf,resultをコンソールログで確認したところ正常に値が入ってはいるのですがなぜか一瞬で表示が消えてしましました。
294
+
295
+ ```JavaScript
296
+
297
+ function setDownloadBox(){
298
+
299
+ //alert('check');
300
+
301
+ $.ajax({
302
+
303
+ type:'POST',
304
+
305
+ url :'getCSV.php',
306
+
307
+ data:{key:'value'}
308
+
309
+ }).fail(function(){
310
+
311
+ alert('error');
312
+
313
+ }).done(function(buf){
314
+
315
+ //alert('check');
316
+
317
+ result = JSON.parse(buf);
318
+
319
+ for(var value of result){
320
+
321
+ $('#downloadBox').append(`<a href="csv/`+ value +`" download="` + value + `">` + value + `</a><br>`);
322
+
323
+ }
324
+
325
+ //alert('check');
326
+
327
+ });
328
+
329
+ }
330
+
331
+ ```