質問編集履歴

1

書式の改善

2016/02/19 07:14

投稿

winkle
winkle

スコア9

test CHANGED
File without changes
test CHANGED
@@ -14,166 +14,170 @@
14
14
 
15
15
 
16
16
 
17
- > <!-- 親選択肢 -->
17
+ ```<!-- 親選択肢 -->
18
18
 
19
- <select id="SEL1" name="SEL1">
19
+ <select id="SEL1" name="SEL1">
20
20
 
21
- <option value="">---</option>
21
+ <option value="">---</option>
22
22
 
23
- <?php
23
+ <?php
24
24
 
25
- foreach ($parent_list as $parent => $children_list) {
25
+ foreach ($parent_list as $parent => $children_list) {
26
26
 
27
- echo '<option value="'.$parent.'"';
27
+ echo '<option value="'.$parent.'"';
28
28
 
29
- if ($parent == $_GET['SEL1']){
29
+ if ($parent == $_GET['SEL1']){
30
30
 
31
- echo 'selected';
31
+ echo 'selected';
32
32
 
33
- }
33
+ }
34
34
 
35
- echo '>'.$parent.'</option>';
35
+ echo '>'.$parent.'</option>';
36
36
 
37
- }
37
+ }
38
38
 
39
- ?>
39
+ ?>
40
40
 
41
- </select>
41
+ </select>
42
42
 
43
- <!-- 子選択肢 -->
43
+ <!-- 子選択肢 -->
44
44
 
45
- <select id="SEL2" name="SEL2">
45
+ <select id="SEL2" name="SEL2">
46
46
 
47
- <option value="">---</option>
47
+ <option value="">---</option>
48
48
 
49
- <?php
49
+ <?php
50
50
 
51
- foreach ($parent_list as $parent => $children_list) {
51
+ foreach ($parent_list as $parent => $children_list) {
52
52
 
53
- echo '<optgroup label="'.$parent.'">';
53
+ echo '<optgroup label="'.$parent.'">';
54
54
 
55
- foreach ($children_list as $children => $grandson_list) {
55
+ foreach ($children_list as $children => $grandson_list) {
56
56
 
57
- $view_children = str_replace($parent,"",$children);
57
+ $view_children = str_replace($parent,"",$children);
58
58
 
59
- echo '<option value="'.$children.'"';
59
+ echo '<option value="'.$children.'"';
60
60
 
61
- if ($children == $_GET['SEL2']){
61
+ if ($children == $_GET['SEL2']){
62
62
 
63
- echo 'selected';
63
+ echo 'selected';
64
64
 
65
- }
65
+ }
66
66
 
67
- echo '>'.$view_children.'</option>';
67
+ echo '>'.$view_children.'</option>';
68
68
 
69
- }
69
+ }
70
70
 
71
- echo '</optgroup>';
71
+ echo '</optgroup>';
72
72
 
73
- }
73
+ }
74
74
 
75
- ?>
75
+ ?>
76
76
 
77
77
  </select>
78
78
 
79
79
 
80
80
 
81
- > <script type = "text/javascript">
81
+ <script type = "text/javascript">
82
82
 
83
- > <!--
83
+ <!--
84
84
 
85
- > function ConnectedSelect(selIdList){
85
+ function ConnectedSelect(selIdList){
86
86
 
87
- > for(var i=0;selIdList[i];i++) {
87
+ for(var i=0;selIdList[i];i++) {
88
88
 
89
- > var CS = new Object();
89
+ var CS = new Object();
90
90
 
91
- > var obj = document.getElementById(selIdList[i]);
91
+ var obj = document.getElementById(selIdList[i]);
92
92
 
93
- > if(i){
93
+ if(i){
94
94
 
95
- > CS.node=document.createElement('select');
95
+ CS.node=document.createElement('select');
96
96
 
97
- > var GR = obj.getElementsByTagName('optgroup');
97
+ var GR = obj.getElementsByTagName('optgroup');
98
98
 
99
- > while(GR[0]) {
99
+ while(GR[0]) {
100
100
 
101
- > CS.node.appendChild(GR[0].cloneNode(true));
101
+ CS.node.appendChild(GR[0].cloneNode(true));
102
102
 
103
- > obj.removeChild(GR[0]);
103
+ obj.removeChild(GR[0]);
104
104
 
105
- > }
105
+ }
106
106
 
107
- > obj.disabled = true;
107
+ obj.disabled = true;
108
108
 
109
- > }
109
+ }
110
110
 
111
- > if(selIdList[i+1]) {
111
+ if(selIdList[i+1]) {
112
112
 
113
- > CS.nextSelect = document.getElementById(selIdList[i+1]);
113
+ CS.nextSelect = document.getElementById(selIdList[i+1]);
114
114
 
115
- > obj.onchange = function(){ConnectedSelectEnabledSelect(this)};
115
+ obj.onchange = function(){ConnectedSelectEnabledSelect(this)};
116
116
 
117
- > } else {
117
+ } else {
118
118
 
119
- > CS.nextSelect = false;
119
+ CS.nextSelect = false;
120
120
 
121
- > }
121
+ }
122
122
 
123
- > obj.ConnectedSelect = CS;
123
+ obj.ConnectedSelect = CS;
124
124
 
125
- > }
125
+ }
126
126
 
127
- > }
127
+ }
128
128
 
129
- >
130
129
 
131
- > function ConnectedSelectEnabledSelect(oSel){
132
130
 
133
- > var oVal = oSel.options[oSel.selectedIndex].value;
131
+ function ConnectedSelectEnabledSelect(oSel){
134
132
 
135
- > if(oVal) {
133
+ var oVal = oSel.options[oSel.selectedIndex].value;
136
134
 
137
- > while(oSel.ConnectedSelect.nextSelect.options[1])oSel.ConnectedSelect.nextSelect.remove(1);
135
+ if(oVal) {
138
136
 
139
- > var eF = false;
137
+ while(oSel.ConnectedSelect.nextSelect.options[1])oSel.ConnectedSelect.nextSelect.remove(1);
140
138
 
141
- > for(var OG=oSel.ConnectedSelect.nextSelect.ConnectedSelect.node.firstChild;OG;OG=OG.nextSibling) {
139
+ var eF = false;
142
140
 
143
- > if(OG.label == oVal) {
141
+ for(var OG=oSel.ConnectedSelect.nextSelect.ConnectedSelect.node.firstChild;OG;OG=OG.nextSibling) {
144
142
 
145
- > eF = true;
143
+ if(OG.label == oVal) {
146
144
 
147
- > for(var OP=OG.firstChild;OP;OP=OP.nextSibling)
145
+ eF = true;
148
146
 
149
- > oSel.ConnectedSelect.nextSelect.appendChild(OP.cloneNode(true));
147
+ for(var OP=OG.firstChild;OP;OP=OP.nextSibling)
150
148
 
151
- > break;
149
+ oSel.ConnectedSelect.nextSelect.appendChild(OP.cloneNode(true));
152
150
 
153
- > }
151
+ break;
154
152
 
155
- > }
153
+ }
156
154
 
157
- > oSel.ConnectedSelect.nextSelect.disabled = !eF;
155
+ }
158
156
 
159
- > } else {
157
+ oSel.ConnectedSelect.nextSelect.disabled = !eF;
160
158
 
161
- > oSel.ConnectedSelect.nextSelect.selectedIndex = 0;
159
+ } else {
162
160
 
163
- > oSel.ConnectedSelect.nextSelect.disabled = true;
161
+ oSel.ConnectedSelect.nextSelect.selectedIndex = 0;
164
162
 
165
- > }
163
+ oSel.ConnectedSelect.nextSelect.disabled = true;
166
164
 
167
- > if(oSel.ConnectedSelect.nextSelect.onchange)oSel.ConnectedSelect.nextSelect.onchange();
165
+ }
168
166
 
169
- > }
167
+ if(oSel.ConnectedSelect.nextSelect.onchange)oSel.ConnectedSelect.nextSelect.onchange();
170
168
 
171
- >
169
+ }
172
170
 
173
- > ConnectedSelect(['SEL1','SEL2']);
174
171
 
175
- >
176
172
 
177
- > //-->
173
+ ConnectedSelect(['SEL1','SEL2']);
178
174
 
175
+
176
+
177
+ //-->
178
+
179
- > </script>
179
+ </script>
180
+
181
+ コード
182
+
183
+ ```