selectcitys.blade.php 761 B

1234567891011121314151617181920212223
  1. @foreach ($citys as $city)
  2. <li>
  3. <label class='checkbox-inline'>
  4. <input type='checkbox' class='city' style='margin-top:8px;' city="{{ $city['areaname'] }}" city_id="{{ $city['id'] }}" /> {{ $city['areaname'] }}
  5. </label>
  6. </li>
  7. @endforeach
  8. <script>
  9. $('.city').click(function(){
  10. var checked = $(this).get(0).checked;
  11. var cityall = $(this).parent().parent().parent().parent().find('.cityall');
  12. if(checked){
  13. cityall.get(0).checked = true;
  14. }
  15. var count = cityall.parent().parent().find('.city:checked').length;
  16. if(count>0){
  17. cityall.next().html("(" + count + ")") ;
  18. }
  19. else{
  20. cityall.next().html("");
  21. }
  22. });
  23. </script>