1

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.

0

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 :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.