0

I would like to not display the checkbox that has the value equal to zero. Is there any way of using Jquery(or any other way that I have not tagged) to achieve this?

Blade syntax below:

@foreach ($displays as $display)
   <div class="divclass">
      <input name="subject{{$display->subject}}" id="list" type="checkbox" value="{{$display->id}}">{{$display->name}}
   </div>
@endforeach

One of the {{$display->id}} is zero and so how could I ensure that the div does not get displayed?

3
  • 1
    what about if statement inside foreach? Commented Aug 19, 2015 at 4:04
  • 1
    inside your @foreach put @if ($display->id != 0) Commented Aug 19, 2015 at 4:05
  • 1
    ahh I didnt know you could do that. cheers Commented Aug 19, 2015 at 4:08

2 Answers 2

2
@foreach ($displays as $display)
   if($display->id != 0)
   {
    <div>
      <input name="subject{{$display->subject}}" id="list" type="checkbox" value="{{$display->id}}">{{$display->name}}
    </div>
   }
@endforeach

you can use the the value is not equal to 0 the only enter into the div tag otherwise dont enter then it will not display the check box.

Sign up to request clarification or add additional context in comments.

Comments

1

Try like this :

@foreach ($displays as $display)
 @if ($display->id != 0)
   <div class="divclass"><input name="subject{{$display->subject}}" id="list" type="checkbox" value="{{$display->id}}">{{$display->name}}</div>
 @endif
@endforeach

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.