質問編集履歴
5
一部間違い修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -344,6 +344,26 @@
|
|
344
344
|
|
345
345
|
</select>
|
346
346
|
|
347
|
+
</div>
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
<div>個数
|
354
|
+
|
355
|
+
<select name="items[1]quantity" id="quantity" class="form-control">
|
356
|
+
|
357
|
+
<option value="1">1</option>
|
358
|
+
|
359
|
+
<option value="2">2</option>
|
360
|
+
|
361
|
+
<option value="3">3</option>
|
362
|
+
|
363
|
+
<option value="4">4</option>
|
364
|
+
|
365
|
+
<option value="5">5</option>
|
366
|
+
|
347
367
|
</select>
|
348
368
|
|
349
369
|
</div>
|
@@ -352,28 +372,6 @@
|
|
352
372
|
|
353
373
|
|
354
374
|
|
355
|
-
<div>個数
|
356
|
-
|
357
|
-
<select name="items[1]quantity" id="quantity" class="form-control">
|
358
|
-
|
359
|
-
<option value="1">1</option>
|
360
|
-
|
361
|
-
<option value="2">2</option>
|
362
|
-
|
363
|
-
<option value="3">3</option>
|
364
|
-
|
365
|
-
<option value="4">4</option>
|
366
|
-
|
367
|
-
<option value="5">5</option>
|
368
|
-
|
369
|
-
</select>
|
370
|
-
|
371
|
-
</div>
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
375
|
<button name="button" type="submit" class="btn btn-primary">購入する</button>
|
378
376
|
|
379
377
|
<script>
|
4
解決したコード
test
CHANGED
File without changes
|
test
CHANGED
@@ -251,3 +251,159 @@
|
|
251
251
|
CSS
|
252
252
|
|
253
253
|
JS
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
### 結果
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
```HTML&JS
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
<html>
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
<form id="form" action="https://〜" class="form-inline" method="post">
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
<input type="hidden" name="is_multiple_item" id="is_multiple_item" value="true" />
|
274
|
+
|
275
|
+
<input type="hidden" name="items[0]id" id="id1" value="60" />
|
276
|
+
|
277
|
+
<input type="hidden" name="items[0]cart_item_type" value="single_product" />
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
<div class="form-group">
|
282
|
+
|
283
|
+
<select name="items[0]option_values[0][id]" id="option_values_0_id">
|
284
|
+
|
285
|
+
<option value="415">テスト1</option>
|
286
|
+
|
287
|
+
<option value="416">テスト2</option>
|
288
|
+
|
289
|
+
<option value="417">テスト3</option>
|
290
|
+
|
291
|
+
</select>
|
292
|
+
|
293
|
+
</div>
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
<div>個数
|
298
|
+
|
299
|
+
<select name="items[0]quantity" id="quantity1" class="form-control custom_quantity">
|
300
|
+
|
301
|
+
<option value="1">1</option>
|
302
|
+
|
303
|
+
<option value="2">2</option>
|
304
|
+
|
305
|
+
<option value="3">3</option>
|
306
|
+
|
307
|
+
<option value="4">4</option>
|
308
|
+
|
309
|
+
<option value="5">5</option>
|
310
|
+
|
311
|
+
</select>
|
312
|
+
|
313
|
+
</div>
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
<input type="hidden" name="items[1]cart_item_type" value="regular_course" />
|
318
|
+
|
319
|
+
<input type="hidden" name="items[1]id" id="id" value="16" />
|
320
|
+
|
321
|
+
<input type="hidden" name="items[1]products[][variant_id]" value="" />
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
<div class="form-group">
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
<select name="items[1]option_values[1][id]" id="option_values_1_id">
|
334
|
+
|
335
|
+
<option value="679">A</option>
|
336
|
+
|
337
|
+
<option value="481">B</option>
|
338
|
+
|
339
|
+
<option value="44">C</option>
|
340
|
+
|
341
|
+
<option value="43">D</option>
|
342
|
+
|
343
|
+
<option value="42">E</option>
|
344
|
+
|
345
|
+
</select>
|
346
|
+
|
347
|
+
</select>
|
348
|
+
|
349
|
+
</div>
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
<div>個数
|
356
|
+
|
357
|
+
<select name="items[1]quantity" id="quantity" class="form-control">
|
358
|
+
|
359
|
+
<option value="1">1</option>
|
360
|
+
|
361
|
+
<option value="2">2</option>
|
362
|
+
|
363
|
+
<option value="3">3</option>
|
364
|
+
|
365
|
+
<option value="4">4</option>
|
366
|
+
|
367
|
+
<option value="5">5</option>
|
368
|
+
|
369
|
+
</select>
|
370
|
+
|
371
|
+
</div>
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
<button name="button" type="submit" class="btn btn-primary">購入する</button>
|
378
|
+
|
379
|
+
<script>
|
380
|
+
|
381
|
+
const input = document.getElementsByTagName("input")[5];
|
382
|
+
|
383
|
+
const select = document.getElementById("option_values_1_id");
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
input.value = select.value;
|
388
|
+
|
389
|
+
console.log(input.value);
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
select.addEventListener("change", () => {
|
394
|
+
|
395
|
+
input.value = select.value;
|
396
|
+
|
397
|
+
console.log(input.value);
|
398
|
+
|
399
|
+
});
|
400
|
+
|
401
|
+
</script>
|
402
|
+
|
403
|
+
</form>
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
</html>
|
408
|
+
|
409
|
+
```
|
3
画像添付
test
CHANGED
File without changes
|
test
CHANGED
@@ -234,6 +234,18 @@
|
|
234
234
|
|
235
235
|
### 補足情報(FW/ツールのバージョンなど)
|
236
236
|
|
237
|
+
|
238
|
+
|
239
|
+
![イメージ説明](1d5917b5df87167dd2583d3a2fb19579.png)
|
240
|
+
|
241
|
+
画像のように、赤枠部分に値が入っていない....
|
242
|
+
|
243
|
+
ここに値が入ればうまくいくはず...
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
237
249
|
HTML
|
238
250
|
|
239
251
|
CSS
|
2
どこが影響しているかわからないので、割愛してたソースコード追記。
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,47 @@
|
|
34
34
|
|
35
35
|
|
36
36
|
|
37
|
+
<input type="hidden" name="is_multiple_item" id="is_multiple_item" value="true" />
|
38
|
+
|
39
|
+
<input type="hidden" name="items[0]id" id="id" value="60" />
|
40
|
+
|
41
|
+
<input type="hidden" name="items[0]cart_item_type" value="single_product" />
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
<div class="form-group">
|
46
|
+
|
47
|
+
<select name="items[0]option_values[0][id]" id="option_values_0_id">
|
48
|
+
|
49
|
+
<option value="415">テスト1</option>
|
50
|
+
|
51
|
+
<option value="416">テスト2</option>
|
52
|
+
|
53
|
+
<option value="417">テスト3</option>
|
54
|
+
|
55
|
+
</select>
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
|
60
|
+
|
37
|
-
|
61
|
+
<div>個数
|
62
|
+
|
63
|
+
<select name="items[0]quantity" id="quantity" class="form-control custom_quantity">
|
64
|
+
|
65
|
+
<option value="1">1</option>
|
66
|
+
|
67
|
+
<option value="2">2</option>
|
68
|
+
|
69
|
+
<option value="3">3</option>
|
70
|
+
|
71
|
+
<option value="4">4</option>
|
72
|
+
|
73
|
+
<option value="5">5</option>
|
74
|
+
|
75
|
+
</select>
|
76
|
+
|
77
|
+
</div>
|
38
78
|
|
39
79
|
|
40
80
|
|
1
追記してみたが..
test
CHANGED
File without changes
|
test
CHANGED
@@ -148,6 +148,50 @@
|
|
148
148
|
|
149
149
|
|
150
150
|
|
151
|
+
|
152
|
+
|
153
|
+
以下追加してみてもダメ...
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
<script type="text/javascript">
|
158
|
+
|
159
|
+
<!--
|
160
|
+
|
161
|
+
window.onload = function () {
|
162
|
+
|
163
|
+
//@cc_on
|
164
|
+
|
165
|
+
document./*@if (1)attachEvent('on'+ @else@*/addEventListener(/*@end@*/
|
166
|
+
|
167
|
+
'change', function (evt) {
|
168
|
+
|
169
|
+
var e = evt./*@if (@_jscript) srcElement @else@*/ target /*@end@*/;
|
170
|
+
|
171
|
+
if (e.type=="select-one" && e.name=="items[1]option_values[1][id]"){
|
172
|
+
|
173
|
+
alert(e.value);
|
174
|
+
|
175
|
+
var elements = document.getElementsByName("items[1]products[][variant_id]");
|
176
|
+
|
177
|
+
elements[0].value=e.value;
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
}, true);
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
// -->
|
186
|
+
|
187
|
+
</script>
|
188
|
+
|
189
|
+
```
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
151
195
|
### 補足情報(FW/ツールのバージョンなど)
|
152
196
|
|
153
197
|
HTML
|