Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Stefan Lexow on May 11, 2008 09:20
open dhtmlx forum
dhtmlxCombo Change font style for one element

Hi!

I have a question concerning the combo-box. I'm filling the box with values I generate throw a mysql query and assign the return values to the box. Further I initialize the combo box with a default text. This one i set wit setComboText. And exactly this text should be displayed in another font color to display the user, wheter he has choosen a value from the box or the box is set to default.

How would this be possible?

Stefan
Answer posted by Support on May 12, 2008 07:55
If you set default option, you can set especial style for the combo input element:

z.setComboText(...);
z.DOMelem_input.style.color= 'blue';

And when used change option from the list, you should set another color:

z.attachEvent("onChange",function(){

    z.DOMelem_input.style.color= 'black';

})
Answer posted by Stefan Lexow on May 13, 2008 08:26
Thanks for you reply, but it that didn't worked for me.

I defined a div like that:
<div id="input_organismus"style="width:120px; height:30px;"></div>

Here is the initialisation-code for the combo box:

<script language="javascript"> 
        var organismus=new dhtmlXCombo("input_organismus","organismus",120);


HERE I SET THE STANDARD VALUE/LABEL
organismus.addOption(0,"organism");
organismus.selectOption(organismus.getIndexByValue(0));

       //Here I initialized $jsstring from php with valid values. Works fine :)
   organismus.addOption([<?php echo $jsstring ?>]);
</script>   
   


So everything is fine and it works, but when i try to set a color for the standard value, even during initialisation with css like

organismus.addOption(0,"oganismus","color: red;");

it doesn't work.

And when I try to access the element of the ComboBox via DOM (the way you showed me):
organismus.organismus.style.color='red';

I get a JS "no properties" error.

I think I have a stupid error in it, but I couldn't find it. Maybe you can help me again.

Greetings Stefan Lexow