質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -55,3 +55,107 @@
|
|
55
55
|
]
|
56
56
|
|
57
57
|
```
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
実際にやりたいのはこのような感じです
|
64
|
+
|
65
|
+
phpで出力した配列をjsで受け取り、セレクトボックスに値を入れたいです
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
```php
|
70
|
+
|
71
|
+
<?php
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
defined('_JEXEC') or die;
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
$db = JFactory::getDBO();
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
$cgr_array = array();
|
84
|
+
|
85
|
+
$sql = 'select items_main,items_sub,items_datails,keyword from table_field group by items_main,items_sub,items_datails,keyword';
|
86
|
+
|
87
|
+
$db->setQuery($sql);
|
88
|
+
|
89
|
+
$results = $db->loadRowList();
|
90
|
+
|
91
|
+
$i = 0;
|
92
|
+
|
93
|
+
foreach ($results as $row) {
|
94
|
+
|
95
|
+
$cgr_array2 = array($results[$i]['0'], $results[$i]['1'], $results[$i]['2'], $results[$i]['3']);
|
96
|
+
|
97
|
+
array_push($cgr_array, $cgr_array2 );
|
98
|
+
|
99
|
+
$i += 1;
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
$i = 0;
|
106
|
+
|
107
|
+
$full_string = '';
|
108
|
+
|
109
|
+
$full_string .= '
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
<script>
|
114
|
+
|
115
|
+
' . json_encode($cgr_array,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES) . '
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
$(document).ready(function(){
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
//ここで配列の内容を取得して配列の内容に応じてセレクトボックスに値を入れたい
|
124
|
+
|
125
|
+
fetch(document.forms).then(res=>res.json()).then(data=>{
|
126
|
+
|
127
|
+
if(配列-大分類==""){
|
128
|
+
|
129
|
+
if(配列-中分類==""){
|
130
|
+
|
131
|
+
$("#sbox-keywords").append("<option value=" + 配列-キーワード + ">" + word + "</option>");
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
}else{
|
136
|
+
|
137
|
+
$("#sbox-keywords").append("<option value=" + word + ">" + 配列-キーワード + "</option>");
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
});
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
});
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
</script>
|
152
|
+
|
153
|
+
';
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
echo $full_string;
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
```
|