Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var ViewModel = function () {
- self.programs = ko.observableArray([
- {programId: 1, programDescription: 'One'},
- {programId: 2, programDescription: 'Two'},
- {programId: 3, programDescription: 'Three'}
- ]);
- self.program = ko.observable();
- self.saveProgram = function () {
- for (i = 0; i < self.programs().length - 1 ; i++) {
- if (self.programs()[i].programId == self.program().programId) {
- self.programs()[i].programDescription =
- self.program().programDescription;
- alert(self.programs()[i].programDescription);
- }
- }
- };
- };
- ko.applyBindings(new ViewModel());
- <div>
- <select data-bind="options: programs,
- optionsText: 'programDescription',
- value: program"></select>
- </div>
- <div>
- Update Program Description: <input type="text" data-bind="value: program().programDescription" />
- <button type="button" data-bind="click: saveProgram">Update</button>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement