Hey there I'm new to web developing and currently working on a project based on laravel framework. This is my code where all check boxes are displayed and based on database values they should be checked but I'm confuse in jquery side
Html Blade code:
@foreach ($param as $value)
<input type="checkbox" name="param1[]" id="param1" value="{{$value->id}}"
<label> {{$value->parameters}}</label><br>
@endforeach
Here Values are 1,2,3,4,5
and data coming from db is 1,2,3
so only those are to checked
Here's my Jquery Code:
$(".edit").click(function() {
$("#exampleModal1").modal('show');
$tr = $(this).closest('tr');
var data = $tr.children("td").map(function() {
return $(this).text();
}).get();
$("#sub").val(data[2]);
id = data[0];
var _token = $('input[name="_token"]').val();
console.log(_token);
$.ajax({
url: "{{route('admin.getparam')}}",
type: "post",
data: {
"cp_id": data[1],
"_token": _token
},
success: function(response) {
var arr = $.parseJSON(response);
//alert(arr);
$.each(arr, function(i, v) {
alert($('#param1').val());
//alert(v);
});
}
});
});
I need code to put only those check box checked please help