Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by gatotkaca on Mar 25, 2009 19:56
open dhtmlx forum
set selected option in dhtmlxcombo

dear all,
thanks for your response on my previous question.

i have one question in dhtmlxcombo , how to set option became selected for data from xml?

i have xml data sample like this
<?php
header("Content-type:text/xml");
print("<?xml version=\"1.0\"?>");
echo "<complete>";
echo '<option value="1">b1_'.$_GET['name'].'</option>
    <option value="2">b2_</option>
    <option value="3" selectedd>b3_</option>
    <option value="4">b4_</option>
    <option value="5">b5_</option>
    <option value="6">b6_</option>
    <option value="7">b7_</option>
    <option value="8">b8_</option>
    <option value="9">b9_</option>';
echo "</complete>";

?>

<div id='div_city' style='width:200px; height:30px;'></div>
<script>
    var combocity = new dhtmlXCombo('div_city','city',200);
    combocity.enableOptionAutoWidth(1);
    combocity.attachEvent('onChange',onChangeFunc);
    combocity.loadXML('processor.php?fid=3&name='+customerName.value);
</script>

i try change in xml data show as bold option but it's not working
any suggestion for my problem?
thanx
Answer posted by Alex (support) on Mar 26, 2009 01:51

Hello, 

The attributes in the xml must have values. So, please, try to use the following syntax to set selected option in the xml:

  <option value="3" selected="1">b3_</option>