I'm working on dependendable dropdown using Javascript and jQuery Ajax fetching the database from database.
First Dropdown menu :
$(document).ready(function () {
$(function() {
$.ajax({
type: 'POST',
url: 'getGroupzBase.php',
datatype: 'json',
success: function(data) {
// Call this function on success
console.log(data);
var yourArray = JSON.parse(data);
console.log(yourArray);
$.each(yourArray, function (index, yourArray) {
$('#builder_group').append($('<option/>', {
value: yourArray.id,
text : yourArray.name,
}));
});
},
error: function() {
displayDialogBox('Error', err.toString());
}
});
});
HTML :
<select id="builder_group"></select>
Second dropdownmenu :
$(document).ready(function () {
$(function() {
$.ajax({
type: 'POST',
url: 'getGroupzCode.php',
datatype: 'json',
success: function(data) {
// Call this function on success
console.log(data);
var yourArray = JSON.parse(data);
console.log(yourArray);
$.each(yourArray, function (index, yourArray) {
$('#build_group').append($('<option/>', {
value: yourArray.id,
text : yourArray.name,
}));
});
},
error: function() {
displayDialogBox('Error', err.toString());
}
});
});
PHP :
<?php echo $form->dropDownList($model,'selectionList',array('rows'=>6, 'cols'=>50)); ?>
Both this dropdownlists do not work together. What is causing it to not work at the same time.