Select example

by kougiland

HTML

<select data-bind="options: type_options, optionsText: 'text', optionsValue: 'value', optionsCaption:'Select a type...', value: type"></select><br>
<span data-bind="text: type"></span>

JavaScript

var vm = {
    type: ko.observable(),

    type_options: ko.observableArray([
        {"text": "String 1", value:1},
        {"text": "String 2", value:2},
        {"text": "String 3", value: 3},
        {"text": "String 4", value: 4},
        {"text": "String 5", value: 5}
    ])
}

ko.applyBindings(vm);