how to preserve space in HTML select option list<option value='hi this'>hi</option>

Viewed 23083

I have one select control. I try to update this control with jquery but the value after space omitting.

if (brandObj != "") {
    brandObj = eval("(" + brandObj + ")"); 
    $.each(brandObj, function(i, item) {
        $("#<%=listBrand.ClientID%>").append(  "<option value="+ item.Brand + ">" + item.Brand + "</option>");
    });

}

The data which I get from server

enter image description here

But after it render as HTML select , it omit the word after space.whole value is there but once I get the value , it have only half(the value which in double quote). I tried to add &nbsp; but it is showing as it is. it is not rendering as space. please give your suggession.

enter image description here

3 Answers

Thanks to : Milind Anantwar, I adapted his idea and solved a problem that’s been nagging for about 5 days.

    <?php
    foreach($rows as $row):
        $outputstr="$row[Mfrname]";
        $goodstr="<option value='".$outputstr."''>".$outputstr."</option>";
        echo $goodstr;
    endforeach;
    ?>
Related