Categories | Question details Back To List | ||
Accessing the Combobox control after initialization I downloaded your combobox control to test if it is suitable for our needs. The control is simple and easy to use, without much overhead. Great ! However I have an issue in accessing the control after initialization. I initilaized the control from a select control using the following lines of code. z= dhtmlXComboFromSelect("combo1"); z.addOption([[1,'John'],[5,'Mary']]); This creates combobox and works fine. I have another button on the form, which on click, I would like to add a value into combo box. The following is the code <script> function OnButtonClick() { var x= dhtmlXComboFromSelect('combo1'); x.addOption([6,'Bruce']); } </script> The first line returns a javascript error: Line 13: "null" is null or not an object. I tried accessing the element by using document.getElementById('combo1'); This statement returns null. How can I access the existing control by id? Accessing the existing control from various pieces of code is crucial for our project. Unfortunately, we can't have a global javascript variable for a combobox. There could be several combocontrols on the form, which we need to access only by id. Please help me at the earliest possible. Thanks, Niranjan. Answer posted by Support on Mar 13, 2008 02:21 Just use z as the combo object. After z= dhtmlXComboFromSelect("combo1"); command has been done, "combo1" container doesn't exist. var z= dhtmlXComboFromSelect("combo1"); z.addOption([[1,'John'],[5,'Mary']]); function OnButtonClick() { z.addOption([6,'Bruce']); } |