I am using knockoutjs to bind a select list. Here is a Sample , I want to get selected option text instead of selected value.
How to get it using knockoutjs ?
<select id="projectMenu" name="projectMenu" data-bind="
value: selectedProject,
options: projectFilters,
optionsText: 'a',
optionsValue: 'b',
optionsCaption: '-- Select Project --'
">
</select>
<b>Selected Project:</b> <span data-bind="text: selectedProject"></span>
As far I am concerned it is not possible with just a simple binding. But You can easily create computedObservable which choose optionText based on optionValue
The simplest way to do it is to remove the optionsValue binding. When you don't sepcify the optionsValue binding, the entire item will be the selected value.
See fiddle