Return the values from a Dropdown Box

I wish to set two fields based on the Dropdown seelction.

How do we return both the display value and data value of the selected option in a dropdown?

You can use the following JS to the onChange event


var titleValue;

var opts = page.F_DropDownList.getOptions();

for(var i=0;i<opts.length;i++) {
var theItemTitle = get(get(opts,i), 'title');
var theItemValue = get(get(opts,i), 'value');
if(theItemValue === item.getValue()) {
titleValue = theItemTitle;
BO.F_TitleValue.setValue(titleValue);
}
}

Thanks Ken, as you can tell I am a JS newbie

There have been many times that I have wanted to do this too. Ken's suggestion is the only way today. I'll file a feature request to make this easier.