Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by langemi on Mar 12, 2009 16:07
open dhtmlx forum
setting selected value of combobox

Is there a way to set the currently selected value of a combo box using text. I have a text value that I get from a grid and I want to set the value of the combobox using that text (not the value).

Let's say I get the text "RED" from a column in a row selected on a grid and I want cause a "color" combobox to automatically select RED. I don't know the value associated with RED so I can't do it by value. I only have the text.

I tried setComboText and setComboValue and they did not help me out.

Thanks,
Mike
Answer posted by Alex (support) on Mar 13, 2009 06:54

setComboValue allows to select option by value (not by text). So, you can try to use the following approach:

var option= combo.getOptionByLabel("RED");

var val = option.value;

combo.setComboValue(val);