Categories | Question details Back To List | ||
Get object of second Autocomplete combo in onchange() function(inside javascript) of first Autocomplete combo. Hello, I want to get object of second Autocomplete combo in onchange() function(inside javascript) of first Autocomplete combo. I tried doing it through document.getElementById("Second combo id") but could not achieve it instead got null. Im using dhtmlComboFromSelect(...). Plz help me as soon as possible coz its stopping my work. Thank you Answer posted by Alex (support) on Aug 12, 2009 08:17 Hello, after using dhtmlComboFromSelect(...) method the select element is removed - dhtmlxcombo is initialized in the div container. That is why ocument.getElementById(..) returns null. Answer posted by sirisha on Aug 12, 2009 19:38 Hello, Thanks for reply. Then how can i achive this. I need that object. Plz help me. Answer posted by Alex (support) on Aug 13, 2009 02:05 Please explain - why do you need to get select object ? This object doesn't exist after combo initialization and combo API allows to get the information about selected value: combo.getActualValue() (all methods are in dhtmlxCombo/doc/alpha.html). Answer posted by Sirisha on Aug 13, 2009 02:22 hello , thanks for reply. I have gone through all the API but dint find the solution for my problem. BUt will expalin my requirement for why i need it. I have to populate a different list options in second autocomplete combo , when onchange function of first autocomplete combo is triggered. Example: firstcombo has countries--->US,India etc Second combo has states related to each country.SO when i select US as my Country then second combo must be populated with California,New york etc... If i select India in first combo then second combo must get populated with Delhi,Maharastra etc.. For this i need the object of second combo in the first combo's onchange function. By default the second combo will also be existing with few default values.Only that it has to repopulate based on selected value of first combo. Im using dhtmlXComboFromSelect. Both are autocomplete combos itself.How do i achieve this. Plz help me Thank and regards Sirisha
Answer posted by Alex (support) on Aug 13, 2009 02:35 Ok... You have two combos: combo1 = new dhtmlXCombo(...); /*or dhtmlXComboFromSelect(...) - it is doesnt' matter*/ combo2 = new dhtmlXCombo(...); So, in order to repopulate the second combo, you can use the following approach: combo1.attachEvent("onChange",function(){ combo2.clearAll() var value_from_combo1 = combo1.getActualValue(); combo2.addOption(....) /*combo2.loadXML(...)*/ }) Answer posted by sirisha on Aug 13, 2009 02:59 thank you so much. this solved my problem. |