0

I have array checkbox (category) and I want to display list of checkbox size if one of them is being checked. I have already made the JavaScript but it didn't work out. Here's my code:

View

@foreach ($categories as $category)
<div class="mb-0 ml-2">
 <label class="mb-0">
  <input class="category mb-0" id="category" name="category[]" type="checkbox" value="{{ $category->id }}" onChange="this.form.submit()" 
  @if (in_array($category->id, $checkedCat)) checked @endif>
  {{ $category->name }}
 </label>
</div>
@endforeach

<div id="size" class="sizefilter">
//List of size checkbox
</div>

JavaScript

$("#category").on('change', function() {
 if($('input[name="category[]"]:checked'))
 {
    $(".sizefilter").show();
 } else
 {
    $(".sizefilter").hide();
 }
});
hushhush
  • 147
  • 2
  • 10

0 Answers0