Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Tony Webber on Jan 16, 2008 14:11
open dhtmlx forum
OnChange event multi-fires when selecting with mouse.

Hi,
Excellent component thanks.

I am using the OnChange to add the selected Option Text to another list field.

This works fine when I use the keyboard scroll arrows to move down the filtered list and press 'Enter' to select the desired item, but when I select the desired item using the mouse I find that the 'autocompleted' item PLUS my slected item are added to the list, I suspect this means that the OnChange is firing twice.

Please advise, Many thanks.
Answer posted by Support on Jan 17, 2008 02:34
Unfortunately issue can't be reconstructed from our side - event fired only one time in all tested browsers.
If problem still occurs for you - please provide more details about code which you are using ( you can send any kind of sample directly to support@dhtmlx.com )
Answer posted by McRoa on Mar 11, 2008 08:00
Hi,

We encountered the same problem (Combo v.1.2 build 71114): the onChange event was fired twice when selecting an item with the mouse. The code below will demonstrate this:

oContractCombo.attachEvent("onChange", function() {
    alert(oContractCombo.getSelectedText());
});   

This results in two alerts, the first without text and the second with the selected combo item.
This is a simple workaround we use to correct the problem:

oContractCombo.attachEvent("onChange", function() {
    if (oContractCombo.getSelectedValue() != null) alert(oContractCombo.getSelectedText());
});    

Hope this helps.