Hi,
I have a form populated from a XML loading the combo data from a database via combo_connector
I can’t figure out how to set the selected value
Hi,
I have a form populated from a XML loading the combo data from a database via combo_connector
I can’t figure out how to set the selected value
add onXLE event to combo and then select option:
myCombo.attachEvent('onXLE', function() {
myCombo.selectOption(optionIndex);
}
Hi klysial,
thanks for the answer. I’m not sure to understand. the object “myCombo” isn’t create in javascript but in xml so I dont see how to attach the event without the combo name
item type=“combo” label=“Corps de métier” connector="…/views/metier/combo.php" name=“corps_de_metier” offsetLeft=“15”/
Do the following.
myCombo = formObject.getCombo(‘corps_de_metier’);
and then you can use the above
Hi klysial,
I tried the following without success:
metierForm = myLayout3.cells(“b”).attachForm();
metierForm.loadStruct("/views/employe/form_metier.xml");
metierForm.load(’/views/employe/form_metier.php?id=’+uid);
console.log(metierForm);
myCombo = metierForm.getCombo(“corps_de_metier”);
console.log(myCombo);
myCombo.attachEvent(‘onXLE’, function() {
myCombo.selectOption(optionIndex);
});
but myCombo seems to be null:
home.php:296 Uncaught TypeError: Cannot read property ‘attachEvent’ of null
at createWindow (home.php:296)
at window.. (home.php:175)
at window..a.callEvent (dhtmlx.js:9)
at dhtmlx.js:9
form_metier.xml contain:
note that you should address to the combo object after the actual loading of the from structure.
So you should use the callback function.
smth:
metierForm.loadStruct("/views/employe/form_metier.xml",function(){
metierForm.load(’/views/employe/form_metier.php?id=’+uid,function(){
console.log(metierForm);
myCombo = metierForm.getCombo(“corps_de_metier”);
console.log(myCombo);
myCombo.attachEvent(‘onXLE’, function() {
myCombo.selectOption(optionIndex);
});
});
});