want to populate 2nd select box according to 1st select box value.
want to populate 2nd select box according to 1st select box value.

Example : country select based on city and state will be display.
i'm trying like following
function getStateList() {
var aStateList = new Array();
$.ajax({
url: '../../controllers/ajax.php?getstate=1',
type: 'POST',
dataType: 'json'
}).done(function(json){
for (var a = 0; a < json.length; a++) {
console.log(json[a][0]);
console.log(json[a][1]);
aStateList[a] = { 'label': json[a][0], 'value' : json[a][1] };
}
console.log(JSON.stringify(aStateList) );
var final_arr = JSON.stringify(aStateList);
return final_arr;
});
}
var editor;
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: '../../controllers/teacher_observation_LM.php',
table: '#example',
fields: [
{
label: 'Name of Teacher:',
name: 'teacher_observation_LM.teacher_id',
type: 'select'
},
{
label: 'Class:',
name: 'teacher_observation_LM.standard_id',
type: 'select'
}, {
label: 'Section:',
name: 'teacher_observation_LM.section_id',
type: 'select'
},{
label: 'Theme:',
name: 'teacher_observation_LM.theme',
type: 'select',
def: 'Y',
ipOpts: getStateList()
}]
} );
Ajax.php code :
if($_GET['getstate'] == 1)
{
$new[0][0] = 'a';
$new[0][1] = 'aa';
$new[1][0] = 'b';
$new[1][1] = 'bb';
echo json_encode($new);
}
Please help me
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
This blog post should help, it's asking the same thing.
Cheers,
Colin