Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Dawson Irvine on May 26, 2009 21:10
open dhtmlx forum
Attach class to addOption element?

Found your website and it's script and figured they would come in real handy for me... However how can I add a css class to an option element.

in a css file:

.dhx_combobox-action {
    color: #000000;
    text-indent: 22px;
    font-weight: bold;
    font-size: 11px;
    margin-right: 2px;
    background: #ffff99 url("../imgs/gear.png") 4px 3px no-repeat;
}

In my html page:

<script type="text/javascript">
    var z = dhtmlXComboFromSelect('customerid');
    z.readonly(true);
    z.addOption('TV','Test Valuation','dhx_combobox-action") 4px 3px no-repeat;');
    z.attachEvent("onChange",function(){ if(z.getActualValue()=="NEW") { if(confirm("Are you sure you want to create a new client? Any changes you've made will be discarded.")) { window.location="Contents.php"; } else { } } else { } });


Everything seems to be working so far except the css. :-)
Answer posted by Alex (support) on May 27, 2009 05:38

Hello, 

combo allows to set css string as an attribute. It can be done as follows:

 z.addOption([{'value':'TV','text':'Test Valuation','css':'color: #000000; text-indent: 22px; font-weight: bold;...'}]);