Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by ihsany on Dec 20, 2008 08:49
open dhtmlx forum
three dynamic dhtmlxcombos

hi,

i have three dynamic combos in my form. 1. combo changed 2.combo fills dynamically and 2. combo changed 3. combo fills dynamically from server.. when i save form everything is ok..
when i open form for edit, i set all form elements values by javascript and 2.combo and 3.combo has wrong values.
when i set 1. combo value ( combo1.setComboValue("1") ) combo1's onChange event fire and its fill combo2
but other side my javascript code already set combo2's value.. so combo1's onChange event lost combo2's value but i need it
for fill combo2's related values.. so same thing happens for combo3 ..
also i tried some delay code but i think its not an efficient solution. please try similar scenario..
some sample code..

function combo1Changed(){
var id=cmbCodeGroup.getSelectedValue();
if(id){
combo2.clearAll(true);
combo2.loadXML('../../Async/Combo/CodeSubGroup.aspx?id='+id);
//setTimeout("combo2.setComboValue(combo2.getActualValue());",100); // for async delay
}
}
function combo2Changed(){
var id=combo2.getSelectedValue();
if(id){
combo3.clearAll(true);
combo3.loadXML('../../Async/Combo/CodeType.aspx?id='+id);
//setTimeout("combo3.setComboValue(combo3.getActualValue());",100); // for async delay
}
}

please help me, this is urgent..

thanks in advance..
Answer posted by Support on Dec 22, 2008 03:32
You can use second parameter of loadXML to catch moment when combo loaded with data. 


function combo1Changed(){ 
var id=cmbCodeGroup.getSelectedValue(); 
if(id){ 
     var value=combo2.getActualValue();
     combo2.clearAll(true); 
     combo2.loadXML('../../Async/Combo/CodeSubGroup.aspx?id='+id,function(){
          combo2.setComboValue(value); //will be called after data loaded in combo
     });