Master/slave-boxes

Hi!



I am using the group extension of combo boxes, but have two issues.



In one case I am using two combo boxes for browsing, where I have attached an onChange event to the slave boxes that will load the right page as described below (it is done using AJAX, so the comboboxes will remain in the browser and not be reloaded). The problem is that the event seems to be fired not only when the slave-combo (‘objectcombo’) is changed, but also when the master-combo (‘classcombo’) is changed. Is there any way to avoid it?



Code:



var classcombo=new dhtmlXCombo(“search_classcombobox”,“alfa2”,160);

classcombo.enableFilteringMode(true);

classcombo.loadXML(‘ajax/allclasses.php’);

var objectcombo = classcombo.setAutoSubCombo(‘ajax/objectsinclass.php’,‘alpha2’);

objectcombo.attachEvent(‘onChange’,onChangeObjectFunc);





My second question regards another case of master/slave boxes, in this case for editing. In this case I have loaded values both to the master and to the slave from a database and want to be able to show both from the start (i.e. without the user having to do anything). Is it possible?



Best regards,

Gunnar


Hi,


This behaviour is correct.


How does combos work in group ? When the master combo changes, the slave combo changes too. That is why onChange event called for it.


Instead of combo groups you can use own approach based on onChange event handler. For example:


var classcombo=new dhtmlXCombo(“search_classcombobox”,“alfa2”,160);
classcombo.enableFilteringMode(true);
classcombo.loadXML(‘ajax/allclasses.php’);


classcombo.attachEvent(“onChange”,function(){


objectcombo.clearAll();


objectcombo.loadXML(‘ajax/objectsinclass.php?parent=’’+classcombo.getActualValue());


});


var objectcomboo=new dhtmlXCombo(“search_classcombobox”,“alfa3”,160);
objectcombo.loadXML(‘ajax/objectsinclass.php’’);



objectcombo.attachEvent(‘onChange’,onChangeObjectFunc);