回答編集履歴
1
複数対応
answer
CHANGED
@@ -8,4 +8,18 @@
|
|
8
8
|
}, false);
|
9
9
|
```
|
10
10
|
例が一つしかないためちょっとわからなかったのですが、複数行あるのでしょうか?
|
11
|
-
その場合はformで監視したほうがいいかもしれません(idは変える必要があります)。
|
11
|
+
その場合はformで監視したほうがいいかもしれません(idは変える必要があります)。
|
12
|
+
|
13
|
+
-- 15:17追記 複数対応
|
14
|
+
|
15
|
+
```HTML
|
16
|
+
<option value="test_name" data-disp="test_d_name" data-address="test_address">test_name</option>
|
17
|
+
```
|
18
|
+
|
19
|
+
```JavaScript
|
20
|
+
document.getElementById('select_test_info').addEventListener('change', function(event) {
|
21
|
+
var option = this.options[this.selectedIndex];
|
22
|
+
document.querySelector('[name="test_d_name"]').value = option.getAttribute('data-disp');
|
23
|
+
document.querySelector('[name="test_address"]').value = option.getAttribute('data-address');
|
24
|
+
}, false);
|
25
|
+
```
|