How would I go about setting a default value to be selected when a combo box is initialized and initially loaded onto the screen? I am trying to use getIndexByValue(), getOptionByLabel() but these are not working ( I assume these are not working because the combo box is not completely intialized yet). How do I work around this?
combo.loadXML(“initFile.xml”);
combo.getIndexByValue(val); //this returns -1
combo.getOptionByIndex(1); //this returns undefined
combo.getOptionByLabel(val); //this returns null
Hello,
loadXML uses Ajax to load data - asynchronous loading. So, please use the following approach to call the mentioned methods after xml loading:
combo.loadXML(“initFile.xml”,doAfterXMLLoading);
function doAfterXMLLoading(){
var ind = combo.getIndexByValue(val); //this returns -1
var option = combo.getOptionByIndex(1); //this returns undefined
option = combo.getOptionByLabel(val); //this returns null
}