getCombo method not working

I need to build a form with a calendar and some combo controls on it.

When I try to load data from XML to a combo inside the form I am receiving the error “combopayee is null” in FF with FireBug. I’ve searched this forum and documentation but I cannot find a solution.

Here is the main page code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<link rel="stylesheet" type="text/css" href="./../includes/DHTMLX/dhtmlxsuite/dhtmlxfull/dhtmlx.css">
	<script src="./../includes/DHTMLX/dhtmlxsuite/dhtmlxfull/dhtmlx.js"></script>
</head>
 
<body onload="doOnLoad()">
	<div id="form_container" style="width:250px;height:300px;"></div>
	<script>
		window.dhx_globalImgPath="./../includes/DHTMLX/dhtmlxsuite/dhtmlxfull/imgs/";
		var myForm;
		function doOnLoad() {
			myForm = new dhtmlXForm("form_container");
			myForm.loadStruct("data/form_debt.xml");
			var combopayee = myForm.getCombo("payee");
			combopayee.loadXML("data/combo_payee.xml");
				}	
	</script>
 
</body>
</html>

The form structure

<?xml version="1.0" encoding="UTF-8"?>
<items>
   <item type="fieldset" name="data" label="Preencha os Dados" inputWidth="auto">
       <item type="calendar" name="data" label="Data" calendarPosition="right" dateFormat="%Y-%m-%d" position="label-top"/>
       <item type="combo" name="payee" label="Fornecedor" position="label-top"/>
       <item type="button" name="save" value="Proceed"/>
   </item>
</items>

And the XML file

<?xml version="1.0" ?>
  <complete>
     <option value="1">one</option>
     <option value="2">two</option>
     <option value="3">three</option>
     <option value="4">four</option>
     <option value="5">five</option>
     <option value="6">six</option>
     <option value="7">seven</option>
     <option value="8">eight</option>
     <option value="9">nine</option>
     <option value="10">ten</option>
  </complete>

What am I doing wrong?

Change your code like the following:

myForm.loadStruct("data/form_debt.xml",function(){ var combopayee = myForm.getCombo("payee"); combopayee.loadXML("data/combo_payee.xml"); });

Olga,

I made the changes suggested by you but I am still receiving the same error.

Here is the modified code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
       <link rel="stylesheet" type="text/css" href="./../../includes/DHTMLX/dhtmlxsuite/dhtmlxfull/dhtmlx.css">
       <script src="./../../includes/DHTMLX/dhtmlxsuite/dhtmlxfull/dhtmlx.js"></script>
    </head>

    <body onload="doOnLoad()">
       <div id="form_container" style="width:250px;height:300px;"></div>
       <script>
          window.dhx_globalImgPath="./../../includes/DHTMLX/dhtmlxsuite/dhtmlxfull/imgs/";
          var myForm;
          function doOnLoad() {
             myForm = new dhtmlXForm("form_container");
             myForm.loadStruct("data/form_debt.xml",function(){
				var combopayee = myForm.getCombo("payee");
				combopayee.loadXML("data/combo_payee.xml");
				});
                };
       </script>

    </body>
    </html>

Unfortunately we cannot reproduce this issue locally. Can you please provide complete demo where we can reproduce it? You can find tutorial how to create complete demo here docs.dhtmlx.com/doku.php?id=othe … leted_demo

Olga,

As you asked here is the complete demo zip file.

Thanks
compdemo.zip (226 KB)

There is “incorrect xml” error in FF. Please have a look at the article (pay attention at point 3):

docs.dhtmlx.com/doku.php?id=othe … orrect_xml

Thank you very much Alexandra. I will keep this article in my bookmarks just in case. :wink:

For your records: At point 3 of the article is stated that this “Incorrect XML” message “may occur because of any whitespace before <?xml declaration” and in this case it is “FF specific” but Google Chrome presents the same error message.