Categories | Question details Back To List | ||
combo default value on page load Hello, I have a problem with the dhtmlxCombo, I'm a beginner. I load the combo with a XML, for example : <?xml version="1.0" encoding="iso-8859-1" ?> <complete> <option value="10">10</option> <option value="20">20</option> <option value="50">50</option> <option value="100">100</option> </complete> I load it in my page with this command : var f=new dhtmlXCombo("combo_page2","alfa2",40); f.loadXML("data.xml"); I would to set a default value when my page load for the first time but it depend of a php variable. I try this for test (without my php variable) : f.selectOption(1); But this is not ok I succed it when before this command I write an alert, for example: alert('ok'); Do you have a solution for me ? Thank you Answer posted by Alex (support) on Sep 03, 2009 01:34 Hello, The default option can be set in the xml by selected attribute: <option selected="1" value="20">20</option> Also you can select option by selectOption or setValue method after xml loading: f.loadXML("data.xml",doAfterLoading) function doAfterLoading(){ f.selectOption(1); }); Answer posted by jimmsr on Sep 03, 2009 07:35 Ok, it works. Thank you. |