回答編集履歴

1

chousei

2021/04/02 00:24

投稿

yambejp
yambejp

スコア116720

test CHANGED
@@ -13,3 +13,47 @@
13
13
  });
14
14
 
15
15
  ```
16
+
17
+ (2)は好意的に想像してこんな感じ
18
+
19
+ ```javascript
20
+
21
+ $(function(){
22
+
23
+ var v="";
24
+
25
+ var list={
26
+
27
+ "選択肢1":{"product":"商品名1","id":"name1"},
28
+
29
+ "選択肢2":{"product":"商品名2","id":"name2"},
30
+
31
+ "選択肢3":{"product":"商品名3","id":"name3"},
32
+
33
+ "選択肢4":{"product":"商品名4","id":"name4"},
34
+
35
+ "選択肢5":{"product":"商品名5","id":"name5"},
36
+
37
+ };
38
+
39
+ $('#Select1').on('change',function(){
40
+
41
+ $('#output').empty().append(
42
+
43
+ $("<dt>").text(list[$(this).val()].product),
44
+
45
+ $("<dd>").append($('<input type="text" name="name" required>').attr('id',list[$(this).val()].id).val(v))
46
+
47
+ );
48
+
49
+ });
50
+
51
+ $(document).on('change','[name="name"]',function(){
52
+
53
+ v=$(this).val();
54
+
55
+ });
56
+
57
+ });
58
+
59
+ ```