質問編集履歴

6

2020/09/29 08:06

投稿

Miii
Miii

スコア30

test CHANGED
File without changes
test CHANGED
@@ -290,262 +290,6 @@
290
290
 
291
291
  </body>
292
292
 
293
- </html><DOCTYPE html>
294
-
295
- <html>
296
-
297
- <head>
298
-
299
- <meta charset="UTF-8">
300
-
301
- <meta name="robots" content="noindex,nofollow">
302
-
303
- <meta http-equiv="content-language" content="ja">
304
-
305
- <meta http-equiv="Pragma" content="no-store">
306
-
307
- <meta http-equiv="Cache-Control" content="no-store">
308
-
309
- <meta http-equiv="Expires" content="0">
310
-
311
-
312
-
313
-
314
-
315
- <!-- ビューポートの設定 -->
316
-
317
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
318
-
319
-
320
-
321
-
322
-
323
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
324
-
325
-
326
-
327
- <title>デモ</title>
328
-
329
-
330
-
331
- <style>
332
-
333
- html{
334
-
335
- font-size:20px;
336
-
337
- }
338
-
339
- body{
340
-
341
- margin:30px;
342
-
343
- }
344
-
345
- main{
346
-
347
- background-color:#f8f8f8;
348
-
349
- padding:20px;
350
-
351
- }
352
-
353
- h2{
354
-
355
- font-size:22px;
356
-
357
- }
358
-
359
-
360
-
361
-
362
-
363
- select,input,textarea{
364
-
365
- font-family : inherit;
366
-
367
- font-size:20px;
368
-
369
-
370
-
371
-
372
-
373
- padding:3px;
374
-
375
- border:1px solid black;
376
-
377
- vertical-align:middle;
378
-
379
- }
380
-
381
-
382
-
383
- </style>
384
-
385
- </head>
386
-
387
- <body>
388
-
389
-
390
-
391
-
392
-
393
-
394
-
395
- <main>
396
-
397
- <h1 style="color:black;">DEMO</h1>
398
-
399
-
400
-
401
-
402
-
403
- <!-- 2つめの計算の箇所-->
404
-
405
- <h2>データ名2</h2>
406
-
407
- <select id="subtotal2" style="font-size:18px;width:200px;"></select>
408
-
409
- <p id="subresult2">1</p>
410
-
411
-
412
-
413
- <!-- 2つめの計算の箇所ここまで-->
414
-
415
-
416
-
417
-
418
-
419
-
420
-
421
-
422
-
423
-
424
-
425
-
426
-
427
-
428
-
429
- <HR style="margin: 2em 0 ;">
430
-
431
-
432
-
433
-
434
-
435
- </main>
436
-
437
-
438
-
439
-
440
-
441
-
442
-
443
-
444
-
445
-
446
-
447
-
448
-
449
- <script>
450
-
451
-
452
-
453
- jQuery(function($){
454
-
455
-
456
-
457
- var data2Json= [
458
-
459
- {
460
-
461
- "list": "データを選択してください",
462
-
463
- "value": "1",
464
-
465
- "type":"条AA"
466
-
467
- },
468
-
469
- {
470
-
471
- "list": "aA",
472
-
473
- "value": "1.2",
474
-
475
- "type":"条AA"
476
-
477
- },
478
-
479
- {
480
-
481
- "list": "いB",
482
-
483
- "value": "1.5",
484
-
485
- "type":"条BB"
486
-
487
- },
488
-
489
- {
490
-
491
- "list": "うC",
492
-
493
- "value": "1.8",
494
-
495
- "type":"条CC"
496
-
497
- }
498
-
499
- ];
500
-
501
-
502
-
503
-
504
-
505
-
506
-
507
-
508
-
509
-
510
-
511
-
512
-
513
-
514
-
515
-
516
-
517
-
518
-
519
- $("#subtotal2").append(data2Json.map(
520
-
521
- x => $(`<option value="${x.value}">${x.list}</option>`)));
522
-
523
-
524
-
525
- $('#subtotal2').change(function() {
526
-
527
- $('#subresult2').text($(this).val());
528
-
529
- window.Calc2 = $(this).val();
530
-
531
- //gassanFnc();
532
-
533
- });
534
-
535
-
536
-
537
-
538
-
539
-
540
-
541
-
542
-
543
- });
544
-
545
- </script>
546
-
547
- </body>
548
-
549
293
  </html>
550
294
 
551
295
  ```

5

編集

2020/09/29 08:06

投稿

Miii
Miii

スコア30

test CHANGED
File without changes
test CHANGED
@@ -18,12 +18,14 @@
18
18
 
19
19
  [追記]
20
20
 
21
- json埋め込み書き換えで表示はされるようになったのですが、
21
+ json埋め込み書き換えで表示はされるようになったのですが、
22
22
 
23
23
  実際のデータよりも、プルダウンメニューで多く表示されてしまいます。
24
24
 
25
25
 
26
26
 
27
+
28
+
27
29
 
28
30
 
29
31
  ```html
@@ -116,11 +118,7 @@
116
118
 
117
119
  }
118
120
 
119
- #subresult1:after{
121
+
120
-
121
- content:"円";
122
-
123
- }
124
122
 
125
123
  </style>
126
124
 
@@ -246,25 +244,35 @@
246
244
 
247
245
 
248
246
 
249
- Object.keys(data2Json).forEach(function(key) {
247
+
250
-
251
-
252
-
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
253
- $("#subtotal2").append(data2Json.map(
259
+ $("#subtotal2").append(data2Json.map(
254
-
260
+
255
- x => $(`<option value="${x.value}">${x.list}</option>`)));
261
+ x => $(`<option value="${x.value}">${x.list}</option>`)));
262
+
263
+
264
+
256
-
265
+ $('#subtotal2').change(function() {
266
+
257
-
267
+ $('#subresult2').text($(this).val());
268
+
258
-
269
+ window.Calc2 = $(this).val();
270
+
259
-
271
+ //gassanFnc();
260
-
261
-
262
-
272
+
263
- });
273
+ });
264
-
265
-
266
-
267
-
274
+
275
+
268
276
 
269
277
 
270
278
 
@@ -282,6 +290,262 @@
282
290
 
283
291
  </body>
284
292
 
293
+ </html><DOCTYPE html>
294
+
295
+ <html>
296
+
297
+ <head>
298
+
299
+ <meta charset="UTF-8">
300
+
301
+ <meta name="robots" content="noindex,nofollow">
302
+
303
+ <meta http-equiv="content-language" content="ja">
304
+
305
+ <meta http-equiv="Pragma" content="no-store">
306
+
307
+ <meta http-equiv="Cache-Control" content="no-store">
308
+
309
+ <meta http-equiv="Expires" content="0">
310
+
311
+
312
+
313
+
314
+
315
+ <!-- ビューポートの設定 -->
316
+
317
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
318
+
319
+
320
+
321
+
322
+
323
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
324
+
325
+
326
+
327
+ <title>デモ</title>
328
+
329
+
330
+
331
+ <style>
332
+
333
+ html{
334
+
335
+ font-size:20px;
336
+
337
+ }
338
+
339
+ body{
340
+
341
+ margin:30px;
342
+
343
+ }
344
+
345
+ main{
346
+
347
+ background-color:#f8f8f8;
348
+
349
+ padding:20px;
350
+
351
+ }
352
+
353
+ h2{
354
+
355
+ font-size:22px;
356
+
357
+ }
358
+
359
+
360
+
361
+
362
+
363
+ select,input,textarea{
364
+
365
+ font-family : inherit;
366
+
367
+ font-size:20px;
368
+
369
+
370
+
371
+
372
+
373
+ padding:3px;
374
+
375
+ border:1px solid black;
376
+
377
+ vertical-align:middle;
378
+
379
+ }
380
+
381
+
382
+
383
+ </style>
384
+
385
+ </head>
386
+
387
+ <body>
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+ <main>
396
+
397
+ <h1 style="color:black;">DEMO</h1>
398
+
399
+
400
+
401
+
402
+
403
+ <!-- 2つめの計算の箇所-->
404
+
405
+ <h2>データ名2</h2>
406
+
407
+ <select id="subtotal2" style="font-size:18px;width:200px;"></select>
408
+
409
+ <p id="subresult2">1</p>
410
+
411
+
412
+
413
+ <!-- 2つめの計算の箇所ここまで-->
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+ <HR style="margin: 2em 0 ;">
430
+
431
+
432
+
433
+
434
+
435
+ </main>
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+
445
+
446
+
447
+
448
+
449
+ <script>
450
+
451
+
452
+
453
+ jQuery(function($){
454
+
455
+
456
+
457
+ var data2Json= [
458
+
459
+ {
460
+
461
+ "list": "データを選択してください",
462
+
463
+ "value": "1",
464
+
465
+ "type":"条AA"
466
+
467
+ },
468
+
469
+ {
470
+
471
+ "list": "aA",
472
+
473
+ "value": "1.2",
474
+
475
+ "type":"条AA"
476
+
477
+ },
478
+
479
+ {
480
+
481
+ "list": "いB",
482
+
483
+ "value": "1.5",
484
+
485
+ "type":"条BB"
486
+
487
+ },
488
+
489
+ {
490
+
491
+ "list": "うC",
492
+
493
+ "value": "1.8",
494
+
495
+ "type":"条CC"
496
+
497
+ }
498
+
499
+ ];
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+
512
+
513
+
514
+
515
+
516
+
517
+
518
+
519
+ $("#subtotal2").append(data2Json.map(
520
+
521
+ x => $(`<option value="${x.value}">${x.list}</option>`)));
522
+
523
+
524
+
525
+ $('#subtotal2').change(function() {
526
+
527
+ $('#subresult2').text($(this).val());
528
+
529
+ window.Calc2 = $(this).val();
530
+
531
+ //gassanFnc();
532
+
533
+ });
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+ });
544
+
545
+ </script>
546
+
547
+ </body>
548
+
285
549
  </html>
286
550
 
287
551
  ```

4

データの書き換え

2020/09/26 02:52

投稿

Miii
Miii

スコア30

test CHANGED
File without changes
test CHANGED
@@ -264,32 +264,20 @@
264
264
 
265
265
 
266
266
 
267
- Object.keys(data2Json).forEach(function(key) {
267
+
268
-
269
-
270
-
271
- var d=$('<datalist id="list">').append(data2Json.map(x=>$(`<option value="${x.list}"</option>`)));
268
+
272
-
273
- $("input#subtotal2").append(d);
269
+
274
-
275
-
276
-
277
-
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
278
 
279
279
  });
280
280
 
281
-
282
-
283
-
284
-
285
-
286
-
287
-
288
-
289
-
290
-
291
- });
292
-
293
281
  </script>
294
282
 
295
283
  </body>

3

データの書き換え

2020/09/26 02:35

投稿

Miii
Miii

スコア30

test CHANGED
File without changes
test CHANGED
@@ -24,6 +24,8 @@
24
24
 
25
25
 
26
26
 
27
+
28
+
27
29
  ```html
28
30
 
29
31
  <DOCTYPE html>

2

追記

2020/09/26 02:33

投稿

Miii
Miii

スコア30

test CHANGED
File without changes
test CHANGED
@@ -14,284 +14,284 @@
14
14
 
15
15
 
16
16
 
17
+
18
+
19
+ [追記]
20
+
21
+ json埋め込み書き換えで表示はされるようになったのですが、
22
+
23
+ 実際のデータよりも、プルダウンメニューで多く表示されてしまいます。
24
+
25
+
26
+
17
27
  ```html
18
28
 
19
29
  <DOCTYPE html>
20
30
 
21
- <html>
22
-
23
- <head>
24
-
25
- <meta charset="UTF-8">
26
-
27
- <meta name="robots" content="noindex,nofollow">
28
-
29
- <meta http-equiv="content-language" content="ja">
30
-
31
- <meta http-equiv="Pragma" content="no-store">
32
-
33
- <meta http-equiv="Cache-Control" content="no-store">
34
-
35
- <meta http-equiv="Expires" content="0">
36
-
37
-
38
-
39
-
40
-
41
- <!-- ビューポートの設定 -->
42
-
43
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
44
-
45
-
46
-
47
-
48
-
49
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
50
-
51
-
52
-
53
- <title>デモ</title>
54
-
55
-
56
-
57
- <style>
58
-
59
- html{
60
-
61
- font-size:20px;
62
-
63
- }
64
-
65
- body{
66
-
67
- margin:30px;
68
-
69
- }
70
-
71
- main{
72
-
73
- background-color:#f8f8f8;
74
-
75
- padding:20px;
76
-
77
- }
78
-
79
- h2{
80
-
81
- font-size:22px;
82
-
83
- }
84
-
85
-
86
-
87
-
88
-
89
- select,input,textarea{
90
-
91
- font-family : inherit;
92
-
93
- font-size:20px;
94
-
95
-
96
-
97
-
98
-
99
- padding:3px;
100
-
101
- border:1px solid black;
102
-
103
- vertical-align:middle;
104
-
105
- }
106
-
107
- #subresult1:after{
108
-
109
- content:"円";
110
-
111
- }
112
-
113
- </style>
114
-
115
- </head>
116
-
117
- <body>
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
- <main>
126
-
127
- <h1 style="color:black;">DEMO</h1>
128
-
129
-
130
-
131
-
132
-
133
- <h2>データ名1</h2>
134
-
135
- <input type="text" id="subtotal1" list="list" style="width:200px;">
136
-
137
- <p id="subresult1">0</p>
138
-
139
-
140
-
141
-
142
-
143
- <HR style="margin: 2em 0 ;">
144
-
145
-
146
-
147
-
148
-
149
- </main>
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
- <script>
164
-
165
-
166
-
167
- jQuery(function($){
168
-
169
-
170
-
171
- var sample_list= [
172
-
173
- {
174
-
175
- "list": "aA-3",
176
-
177
- "value": "300",
178
-
179
- "type":"3"
180
-
181
- },
182
-
183
- {
184
-
185
- "list": "いB-4",
186
-
187
- "value": "1000",
188
-
189
- "type":"4"
190
-
191
- },
192
-
193
- {
194
-
195
- "list": "うC-3",
196
-
197
- "value": "2000",
198
-
199
- "type":"3"
200
-
201
- },
202
-
203
- {
204
-
205
- "list": "え-4",
206
-
207
- "value": "300",
208
-
209
- "type":"4"
210
-
211
- },
212
-
213
- {
214
-
215
- "list": "sB-3",
216
-
217
- "value": "1000",
218
-
219
- "type":"3"
220
-
221
- },
222
-
223
- {
224
-
225
- "list": "cC-4",
226
-
227
- "value": "2000",
228
-
229
- "type":"4"
230
-
231
- }
232
-
233
- ];
234
-
235
-
236
-
237
- //1つめの計算
238
-
239
- $.getJSON("static/data1.json", function(sample_list){
240
-
241
- var d=$('<datalist id="list">').append(sample_list.map(x=>$(`<option value="${x.list}"</option>`)));
242
-
243
- $("input#subtotal1").append(d);
244
-
245
-
246
-
247
- $('input#subtotal1').change(function() {
248
-
249
- const value = $(this).val();
250
-
251
- const candidates = sample_list.filter(
252
-
253
- item => item.list == value);
254
-
255
- if (candidates.length > 0){
256
-
257
- $("#subresult1").text(candidates[0].value);
258
-
259
- //計算用変数Calc1に代入
260
-
261
- window.Calc1=candidates[0].value;
262
-
263
- window.hantei=candidates[0].type;
264
-
265
- console.log(hantei);
266
-
267
-
268
-
269
- window.changeValue = window.hantei;
270
-
271
-
31
+ <html>
32
+
33
+ <head>
34
+
35
+ <meta charset="UTF-8">
36
+
37
+ <meta name="robots" content="noindex,nofollow">
38
+
39
+ <meta http-equiv="content-language" content="ja">
40
+
41
+ <meta http-equiv="Pragma" content="no-store">
42
+
43
+ <meta http-equiv="Cache-Control" content="no-store">
44
+
45
+ <meta http-equiv="Expires" content="0">
46
+
47
+
48
+
49
+
50
+
51
+ <!-- ビューポートの設定 -->
52
+
53
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
54
+
55
+
56
+
57
+
58
+
59
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
60
+
61
+
62
+
63
+ <title>デモ</title>
64
+
65
+
66
+
67
+ <style>
68
+
69
+ html{
70
+
71
+ font-size:20px;
72
+
73
+ }
74
+
75
+ body{
76
+
77
+ margin:30px;
78
+
79
+ }
80
+
81
+ main{
82
+
83
+ background-color:#f8f8f8;
84
+
85
+ padding:20px;
86
+
87
+ }
88
+
89
+ h2{
90
+
91
+ font-size:22px;
92
+
93
+ }
94
+
95
+
272
96
 
273
97
 
274
98
 
275
- }else{
276
-
277
-
278
-
279
- }
280
-
281
-
282
-
283
- });
284
-
285
- });
286
-
287
-
288
-
289
- });
290
-
291
- </script>
292
-
293
- </body>
294
-
295
- </html>
99
+ select,input,textarea{
100
+
101
+ font-family : inherit;
102
+
103
+ font-size:20px;
104
+
105
+
106
+
107
+
108
+
109
+ padding:3px;
110
+
111
+ border:1px solid black;
112
+
113
+ vertical-align:middle;
114
+
115
+ }
116
+
117
+ #subresult1:after{
118
+
119
+ content:"円";
120
+
121
+ }
122
+
123
+ </style>
124
+
125
+ </head>
126
+
127
+ <body>
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+ <main>
136
+
137
+ <h1 style="color:black;">DEMO</h1>
138
+
139
+
140
+
141
+
142
+
143
+ <!-- 2つめの計算の箇所-->
144
+
145
+ <h2>データ名2</h2>
146
+
147
+ <select id="subtotal2" style="font-size:18px;width:200px;"></select>
148
+
149
+ <p id="subresult2">1</p>
150
+
151
+
152
+
153
+ <!-- 2つめの計算の箇所ここまで-->
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <HR style="margin: 2em 0 ;">
170
+
171
+
172
+
173
+
174
+
175
+ </main>
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+ <script>
190
+
191
+
192
+
193
+ jQuery(function($){
194
+
195
+
196
+
197
+ var data2Json= [
198
+
199
+ {
200
+
201
+ "list": "データを選択してください",
202
+
203
+ "value": "1",
204
+
205
+ "type":"条AA"
206
+
207
+ },
208
+
209
+ {
210
+
211
+ "list": "aA",
212
+
213
+ "value": "1.2",
214
+
215
+ "type":"条AA"
216
+
217
+ },
218
+
219
+ {
220
+
221
+ "list": "いB",
222
+
223
+ "value": "1.5",
224
+
225
+ "type":"条BB"
226
+
227
+ },
228
+
229
+ {
230
+
231
+ "list": "うC",
232
+
233
+ "value": "1.8",
234
+
235
+ "type":"条CC"
236
+
237
+ }
238
+
239
+ ];
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ Object.keys(data2Json).forEach(function(key) {
248
+
249
+
250
+
251
+ $("#subtotal2").append(data2Json.map(
252
+
253
+ x => $(`<option value="${x.value}">${x.list}</option>`)));
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+ });
262
+
263
+
264
+
265
+ Object.keys(data2Json).forEach(function(key) {
266
+
267
+
268
+
269
+ var d=$('<datalist id="list">').append(data2Json.map(x=>$(`<option value="${x.list}"</option>`)));
270
+
271
+ $("input#subtotal2").append(d);
272
+
273
+
274
+
275
+
276
+
277
+ });
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+ });
290
+
291
+ </script>
292
+
293
+ </body>
294
+
295
+ </html>
296
296
 
297
297
  ```

1

追記

2020/09/26 02:30

投稿

Miii
Miii

スコア30

test CHANGED
File without changes
test CHANGED
@@ -8,6 +8,12 @@
8
8
 
9
9
 
10
10
 
11
+ ※外部jsonデータを変数に入れたり、
12
+
13
+ 書き換えできるところはしています。
14
+
15
+
16
+
11
17
  ```html
12
18
 
13
19
  <DOCTYPE html>