I’ve created a combo and attached an event, but when I call setComboValue (also tried setComboText and DOMelem_input.value) it doesn’t call the attached function. Below is a sample.
function Event() {}
Event.prototype.handler = function() {};
var myEvent = new Event();
var combo = new dhtmlXCombo(…);
combo.loadXML(…);
combo.attachEvent(‘onChange’, myEvent.handler);
combo.setComboValue(‘hello’);
The event doesn’t fire when setComboValue is called, but I can click on the combo and tab away and the event fires for the new value.
Can you tell me if this doesn’t work like I think it should or if I am doing something wrong?
onChange event will be fired in next situations
- option selected by mouse click
- option selected by keyboard and enter key pressed
- option selected by keyboard and tab pressed or focus moved out from control
Event will not be fired on API calls.
Has this changed since last year?
Cuz I’ve got this: (well basically it comes down to this…)
co.attachEvent(“onChange”,function(){
lo.setComboValue(-1);
pr.setComboValue(-1);
}
lo.attachEvent(“onChange”,function(){
alert(‘Changed!’);
}
pr.attachEvent(“onChange”,function(){
alert(‘Changed too!’);
}
And the alerts keep popping up when I change the co-combobox value…
Ow and I forgot to mention, I don’t want them to activate!
Try to use the following instead lo.setComboValue(-1); pr.setComboValue(-1);
lo.selectOption(lo.getIndexByValue("-1"),false,false);
pr.selectOption(lo.getIndexByValue("-1"),false,false);
Great works like a charm!
Cheers!