How 2 synchronize 2 combo box

Hi guys, new here first of all I would like to say thanks for dhtmlx team who made this great script, it’s really very useful and help my work a lot :smiley:.

However I encounter a problem and I wonder if someone could help me find the solution.

I got 2 combo box, one contain list of frame number and the other is list of engine number.

What I want to do is, whenever I change the selection index of one of the combo box, the other combo box also change their selection based on the index number of the selected option.

My code is like this

For combo box 1

Combo Box 2 ( i haven’t add the event to this combo box yet)

Thanks in advance for anyone that could provide a solution :smiley:

Hi,

selectOption causes onChange event. Thefore, you need to use some flag to call event only once.

For example:

var selected = 0; zr.attachEvent('onChange',function(){ if(selected){ selected = 0; } else{ selected = 1; zm.selectOption(zr.getSelectedIndex(),true,true); zm.setComboText('berhasil'); } }); zm.attachEvent('onChange',function(){ if(selected){ selected = 0; } else{ selected = 1; zr.selectOption(zm.getSelectedIndex(),true,true); } });

Hi Alexandra, thanks for the fast response, I try to implement your code but no luck yet :frowning:

could you take a look at my code here bluemon-key.com/indako/ajax/h1/test-so.php did I do it wrongly?

Also did I use the enableAutoWidth correcly? because firefox console display error

Thanks in advance

Hi,

There is enableOptionAutoWidth method and not enableAutoWidth. You need use
zr.enableOptionAutoWidth(1);
zm.enableOptionAutoWidth(1);

Also enableOptionAutoWidth requires the dhtmlxcombo_whp.js being included.

Ah my bad can’t believe I overlook that one >__<,

btw Alexandra I still have problem with synchronizing the 2 combobox, I need the other combobox to follow my selected index, for example in my previous link, when I change one of the combobox to 22222 I need the other combobox to change to 22222 too. I try to implement your script on it but no luck :s

Thanks in advance

Here is the working demo
combo.zip (20.6 KB)