Click here to Skip to main content
15,888,212 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Please help me to find all selected radio button id for below code

Here's an idea of what my HTML looks like

<div ng-app="MyApp">
    <div ng-controller="MyCtrl">
        <div>
            <table cellpadding="2" cellspacing="2" border="1" ng-repeat="dep in DepList track by $index">
                <tr>
                    <th> Name </th>
                </tr>
                <tr ng-repeat="item in ContactsList | findobj: dep.groupid">
                    <td>{{item.name}}</td>
                    <td><input type="radio" name="radius+{{$parent.$index}}" data-ng-value="{{item.id}}" ng-model="UniqueId" selected="true" /></td>
                </tr>
            </table>
        </div>
        <div>
            <button ng-click="Select()">Select</button>
        </div>
    </div>
</div>


And here's my Controller

<script type="text/javascript">
    var myapp1 = angular.module('MyApp', []);
    myapp1.controller('MyCtrl', function ($scope) {
        $scope.DepList = [{ dep: "computer", groupid: "1" }, { dep: "english", groupid: "2" }];
        $scope.ContactsList = [{
            name: "Sijith",
            id: "1",
            groupid: "1"
        }, {
            name: "Deepak",
            id: "1",
            groupid: "2"
        },
          {
              name: "Libi das",
              id: "1",
              groupid: "2"
          }, {
              name: "Noufal",
              id: "1",
              groupid: "1"
          }, {
              name: "Jijo",
              id: "1",
              groupid: "2"
          }];

       
        $scope.Select = function () { alert($scope.UniqueId);};
    });


    myapp1.filter('findobj', function () {
        return function (ContactsList, id) {
            return ContactsList.filter(function (l) {
                if (l.groupid == id) {
                    return true;
                }
            });
        };
    });

</script>


What I have tried:

$scope.SelectRoom = function () {
alert($scope.UniqueId);
};
Posted
Updated 11-Jan-17 23:14pm

1 solution

You can do something like -
JavaScript
$("input[name^='radius']:checked").each(function () {
 //your code
});


Reference:
Attribute Starts With Selector [name^=”value”] | jQuery API Documentation[^]

Hope, it helps :)
 
Share this answer
 
Comments
sijith.ch 12-Jan-17 5:39am    
its working fine, but is there any angularjs method available?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900