Categories | Question details Back To List | ||
get the values from multiple combo boxes based on getElementById Hi, The requirement is that we need to access the dhtmlxcombo using getElementById, for the reason in the page we could have multiple combo box(es). I read and tried to implement as given in <a href:="http://www.dhtmlx.com/docs/products/kb/index.shtml?cat=search&page=1&q=1767&ssr=yes&s=dhtmlxcombo%20+%20getelementbyid">Multiple combos as array of objects</a>, but I am not able to do it. Following is the code snippet: MyHTML page <div id="div_Default#Element:Position#" style="width:125px; height:45px;"></div> <script> var z=new dhtmlXCombo("div_Default#Element:Position#","Default#Element:Position#",115); for (var x = 0 ; x < elementValues.length ; x++ ) { if ((elementOwner[x] == '#Element:UUID#')) { z.addOption([[elementValues[x], elementValues[x]]]); } } z.enableFilteringMode(true); </script> JS File: function changeElementDropdownsValues(elementPosition) { alert('in changeElementDropdownsValues, elementPosition: ' + elementPosition); //returns dynamic value var newElement = document.createElement('DIV'); alert('newElement: ' + newElement); //return '[object]' newElement.id = 'Default_GLCode'+elementPosition; alert('newElement.id: ' + newElement.id); //returning newly created element id var defaultDropDown = document.getElementById(newElement); alert('defaultDropDown: ' + defaultDropDown); //returning 'null' } I will be thankful, if any one could tell me how I could fetch the value in various combo boxes using getElementById? Further, I looked at the API of dhtmlxcombo, but couldn't find the method which could return me the the size of the dhtmlxcombo. Could you please suggest how can I obtain that as well? Thank you in appreciation. Pranav Answer posted by Alex (support) on Feb 25, 2009 03:54 >> I will be thankful, if any one could tell me how I could fetch the value in various combo boxes using getElementById? There is no such an opportunity. dhtmlxcombo is JavaScript object. You can get its value using API: var value = comboObject.getActualValue(); >>Further, I looked at the API of dhtmlxcombo, but couldn't find the method which could return me the the size of the dhtmlxcombo. Could you please suggest how can I obtain that as well? Unfortunately, API doesn't allow to get the number of options. You can try to use the following approach (it is based on the internal property): var count = comboObj.optionsArr.length; Answer posted on Feb 25, 2009 13:01 Hi Alex, Thank you, I really appreciate your prompt reply. By your comments, should we assume, that if their are multiple combo boxes, dhtmlxcombo won't be suitable option to consider? Or, is there a way, we could work it out? Because, what I assume and tested, that using only one object of 'dhtmlXCombo', and populate it based on dynamic id (that's possible), but when we try to access it, it doesn't work. >> <script> var z=new dhtmlXCombo("div_Default#Element:Position#","Default#Element:Position#",115); Am I missing something, Is my approach correct? Is there any possibility that we could achieve this? Thank you, Pranav Answer posted by Support on Feb 26, 2009 08:07 You can create multiple object and access any of them at any moment of time. But combos are separate objects ( not simple HTML elements ) so you will need to have a bit more code to handle such situation <script> var combos=[]; .... combos["#Element:Position#"] = new dhtmlXCombo("div_Default#Element:Position#","Default#Element:Position#",115); With such code you will have collection "combos" and access value of any combo as combos[" position value here "].getActualValue() Answer posted on Feb 26, 2009 17:42 Thank you Alex. Pranav Answer posted on Feb 26, 2009 17:42 Thank you Alex. Pranav |