I have form where i am sending multiple checkbox items as array to controller,
<?php
foreach($groupsArray as $group)
{
?>
<label>
<input type="checkbox" class="icheck" name="groups[]" id="groups" value="<?php echo $group["id"];?>"> <?php echo $group['name']?> </label>
<?php
}
?>
Everything works fine for checkbox values update in database,
Now, what i am doing is, getting values from database and i need to check values which are stored in database,
I am getting below json response from PHP<
groups: [{user_id: "2", group_id: "4", id: "4", name: "system Creators",…}]
Below i used as AJAX
if(objData.groups[0].group_id == $("#groups").val())
{
$("#groups").iCheck('check');
}
With this $("#groups").val(), it always takes values of first checkbox, so there is problem, How can i compare values for all checkboxes with Json? Also if groups array will have multiple values, means multidimensional array, more groups then?
Thanks in advance!