Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Jorge Arzuaga on Mar 06, 2009 09:19
open dhtmlx forum
Create dhtmlXCombo from function JavaScript in execution time

Hi, i need add a dhtmlXCombo but when press a button such as show below, i save the dhtmlXCombo definition in a var ComboObj and this var send to function JavaScript eval(ComboObj); and show undefined, but the load XML is called for the function..!

Thanks..!

function a(){

myNewRow     = document.getElementById('tablaDetalles').insertRow(-1);
                
ComboObj = 'var ComboObj_cuenta_id = new dhtmlXCombo("ComboObj_cuenta_id","cuenta_id","346",true,6);';
ComboObj += 'ComboObj_cuenta_id.enableFilteringMode(true);';
ComboObj += 'ComboObj_cuenta_id.loadXML("../../js/php/complete.php");';

myNewCell        = myNewRow.insertCell(0);
myNewCell.className    = "medio";
myNewCell.align    = "left";
myNewCell.innerHTML    = eval(ComboObj);

}

<input onclick="a()" type="button">
Answer posted by Support on Mar 09, 2009 04:52
In IE , variables defined in "eval" visible only from inside the same eval, and still not accessible from outside. 
You need to use global variable instead of local one, or use execScript instead of eval for IE