Aceman Aceman - 1 year ago 59
Javascript Question

How to modify array with checkbox selection (It's ready just need to modify something)

I'll try to be short and get to the point.

When I choose a role, it adds it to an array with the role's name and whether it's selected or not (with true or false). Actually the array is saved the following way:

"name": "CDB_DBA",
"selected": true
"name": "CONNECT",
"selected": true

and I need it to be saved this way (with the roles I select from the checkbox list):


The array contains the selected roles, I'm sure it's pretty simple to change but I'm new to this and need some help. Thank you in advance. Here's the JSBin link to the project:

JSBin Project

Answer Source

I have updated your link by creating a new array and pushing the value into that array while checking the checkbox

Can you check this is expected? If not please explain it briefly.

please check the below link,js,output

 $scope.updateArray= function(value){
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download