problem onChange event

Greetings, I have two combo, the first with a list of names loaded by xml, the second lists of codes in the list of first names. to select from the list any names, I should automatically change the value from the list of codes. my problem is when I change a code does not change the value in the list of names, I attach the code to see if I can help.

var z = new dhtmlXCombo("comboT", "alfa2", 200); z.loadXML("../../js/php/cargaT.php"); z.attachEvent("onChange",onChangeFunc); z.enableFilteringMode(true);
	function onChangeFunc(){
	//w.setComboValue(z.getSelectedValue());
	w.selectOption(z.getSelectedValue());
		return true;
		} 
		
  </script>
Almacen:
var w = new dhtmlXCombo("comboA", "alfa2", 200); w.loadXML("../../js/php/cargaA.php"); w.attachEvent("onChange",onChangeAlm); w.enableFilteringMode(true); function onChangeAlm(){ z.selectOption(w.getSelectedValue()); return true; }
  </script></td>

Hi,

selectOption takes options index as a parameter. getSelectedValue() returns option value. Therefore, probably it would be more correct to use the following:

function onChangeFunc(){
w.setValue(z.getSelectedValue());
/*or
w.selectOption(w.getIndexByValue(z.getSelectedValue()));
*/
}

function onChangeAlm(){
z.selectOption(z.getIndexByValue(w.getSelectedValue()));
return true;
}

hello, I did what you suggested, but not working now gives me a stack overflow error.

By default selectOption calls onChange event. You should set the 3rd parameter as false:

[code]function onChangeFunc(){
w.setValue(z.getSelectedValue());
/*or
w.selectOption(w.getIndexByValue(z.getSelectedValue()),false,false);
*/
}

function onChangeAlm(){
z.selectOption(z.getIndexByValue(w.getSelectedValue()),false,false);
return true;
}[/code]