javascript - Sequenctial value in select dropdown -
i have 3 select dropdown , want scenarios below:
- if select 1 in dropdown1 other value 2 , 3.
dropdown1:1
dropdown2:2
dropdown3:3
- if select 1 in dropdown2 other like:
dropdown1:3
dropdown2:1
dropdown3:2
- will like:
dropdown1:2
dropdown2:3
dropdown3:1
<body ng-app="my-app" ng-controller="my-controller"> <select class="form-control" ng-options="obj obj.title obj in sequence" ng-model="selectedview1"></select> <select class="form-control" ng-options=" obj.title obj in sequence" ng-model="selectedview2"></select> <select class="form-control" ng-options=" obj.title obj in sequence" ng-model="selectedview3"></select> </body>
please see codepen link.
i added logic of changing other select boxes in case of choosing 1 in first box.
please take here.
using watch
function, can update other boxes when select changed.
$scope.$watch('selectedview1', function(newvalue) { if (newvalue && newvalue.title === 1) { $scope.selectedview2 = $scope.sequence[1]; $scope.selectedview3 = $scope.sequence[2]; } });
Comments
Post a Comment