Magento – magento 2 get value of selected select box using knockout in custom module

knockoutjsmagento2

I have created custom module , in which I have created front end template form using knockout js.
In form I have created a select box.
I want selected option value in form post method and save that value in data base.

Below is my code in html template.

       <select data-bind="
                  optionsValue: 'value',
                    optionsText: 'label',
                    optgroup: [{
                        label: 'Prefix',
                        value: [{
                            label: 'Mr',
                            value: 'Mr'
                        }, {
                            label: 'Mrs',
                            value: 'Mrs'
                        }, {
                            label: 'Miss',
                            value: 'Miss'
                        }
                        ]
                    }]">

            </select>

If any one has did this , please help me.

Best Answer

I got it's solution . change selectbox code in html template.

    <select name=" prefix" id="prefix" data-bind="value: selectedValue">
       <option value="Mr">Mr.</option>
       <option value="Mrs">Mrs.</option>
       <option value="Miss">Miss.</option>
       <option value="Master">Master.</option>
    </select> 

In js file get value using : this.selectedValue = ko.observable();

Thanks :)