javascript/ jquery/ html/ angularjs

I am new to angularjs and learning to code. I have section with three radio buttons and trying to disable other radio buttons on selecting one. Below is my code

 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div class='info-container-content'> <div> <label class="info-container-accent" aria-label="Search By Zipcode and Radius">Search By Zipcode and Radius </label> <input type="radio" name="selectSearch" ng-model="type" /> <input id="search-text-location" type='text' name='zip-location' ng-disabled="" aria-label="Enter Zip Code" placeholder='Enter Zip Code' ng-model="$ctrl.cservice.locsearch.ZipCode" ng-model-options="modelOptions" /> <select name='zip-radius' aria-label="Radius from Zip Code" ng-disabled="" ng-model="$ctrl.cservice.locsearch.SearchRadius" ng-options="item as item.text for item in $ctrl.cservice.locsearch.SearchRadii track by item.value" ng-model-options="modelOptions"></select> </div> <br /> <div> <label class="info-container-accent" aria-label="Search by County">Search by County</label> <input type="radio" name="selectSearch" ng-model="type" /> <select name='loc-county' aria-label="County" ng-disabled="" ng-model="$ctrl.cservice.locsearch.County" ng-options="item as item.RegionName for item in $ctrl.cservice.locsearch.Counties track by item.RegionCode" ng-model-options="modelOptions"> <option value="">Select a County</option> </select> </div> <br /> <div> <label class="info-container-accent" class="info-container-accent" aria-label="Search by Properity Region">Search by Properity Region</label> <input type="radio" name="selectSearch" ng-model="type" /> <select name='loc-region' aria-label="Region" ng-disabled="" ng-model="$ctrl.cservice.locsearch.Region" ng-options="item as item.RegionName for item in $ctrl.cservice.locsearch.Regions track by item.RegionCode" ng-model-options="modelOptions"> <option value="">Select a Region</option> </select> </div> </div> 

kindly help.

You should use ng-value to set the value of each radio button as sample

 var app = angular.module("app", []); 
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="app"> <div class='info-container-content'> <div> <label class="info-container-accent" aria-label="Search By Zipcode and Radius">Search By Zipcode and Radius </label> <input type="radio" name="selectSearch" ng-model="type" ng-value="0" /> <input id="search-text-location" type='text' name='zip-location' ng-disabled="type != 0" aria-label="Enter Zip Code" placeholder='Enter Zip Code' ng-model="$ctrl.cservice.locsearch.ZipCode" ng-model-options="modelOptions" /> <select name='zip-radius' aria-label="Radius from Zip Code" ng-disabled="type != 0" ng-model="$ctrl.cservice.locsearch.SearchRadius" ng-options="item as item.text for item in $ctrl.cservice.locsearch.SearchRadii track by item.value" ng-model-options="modelOptions"></select> </div> <br /> <div> <label class="info-container-accent" aria-label="Search by County">Search by County</label> <input type="radio" name="selectSearch" ng-model="type" ng-value="1"/> <select name='loc-county' aria-label="County" ng-disabled="type != 1" ng-model="$ctrl.cservice.locsearch.County" ng-options="item as item.RegionName for item in $ctrl.cservice.locsearch.Counties track by item.RegionCode" ng-model-options="modelOptions"> <option value="">Select a County</option> </select> </div> <br /> <div> <label class="info-container-accent" class="info-container-accent" aria-label="Search by Properity Region">Search by Properity Region</label> <input type="radio" name="selectSearch" ng-model="type" ng-value="2"/> <select name='loc-region' aria-label="Region" ng-disabled="type != 2" ng-model="$ctrl.cservice.locsearch.Region" ng-options="item as item.RegionName for item in $ctrl.cservice.locsearch.Regions track by item.RegionCode" ng-model-options="modelOptions"> <option value="">Select a Region</option> </select> </div> </div> type is : {{type}} </div> 

暂无
暂无

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Radio buttons to enable/disable fields Javascript to disable or enable radio buttons How to enable disable a select drop down list using radio buttons with angularjs? JavaScript - Checkbox to enable/disable radio buttons enable/disable functionality buttons based on radio button Enable and disable text with radio buttons with javascript? Enable/Disable Submit Button based on radio buttons how to enable and disable radio buttons to checkboxes with JQ Improving use of radio buttons to enable/disable form fields disable-enable a hyperlink by clicking on radio-buttons
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM