Hi, I have a JSon array as below which I need to filter to get the correct child values from the test data below.
var arrChildOptions2 = [{Parent:'opt1',Value:'opt1',Text:'Parent1 - Child 1'},{Parent:'opt2',Value:'opt1',Text:'Parent 2 - Child 1'},{Parent:'opt2',Value:'opt2',Text:'Parent 2 - Child 2'}];
The values are used to populate a dropdown based on the change event of a parent dropdown as below.
$(function() {
$('#ddl1').change(function() {
$('#ddl2 option:gt(0)').remove();
$('#ddl2').addItems('#ddl2', arrChildOptions2[Parent=opt2]);
});
});
where additems is a function that loops through the array. Problem is I can't get it to filter by parent, I've tried using contains and the above arrChildOptions2[Parent=opt2] but I can't get it to filter, I'd prefer to find a neat solution rather than use a for loop? Any ideas, cheers