douyue1481 2017-04-12 07:44
浏览 63

html选中标签更改复选框

how can i do when some option is checked in checkbox, that label showing in select tag? enter image description here

Checkbox input

<input
type="checkbox"
class="toggle-product pull-right" @if(!isset($restrictedProductIds[$p->id])) checked
@endif
data-url="{{route('image.settings.product.toggle',[$account,$album,$image,$p])}}">

Select tag

                    <select name="default_id" id="default_id" class="form-control">
                    <option value="{{$image->default_product_id}}" selected>{{$image->default_product_id}}</option>
                    @foreach($validProducts as $product)
                        @if(!isset($restrictedProductIds[$product->id]))
                        <option value="{{$product->id}}">
                            {{$product->getTranslatedName()}}
                        </option>
                        @endif
                    @endforeach
                </select>

class .toggle-product

            $(".toggle-product").on('click', function () {
                var checked = $(this).is(':checked');
                var $status = $(this).parents(".list-group-item");
                $status.addClass('list-group-item-warning');
                $.post($(this).data('url'), {
                    'enabled': checked ? 1 : 0,
                    '_token': "{{csrf_token()}}"
                }, function (response) {
                    $status.removeClass('list-group-item-warning');
                    //location.reload();
                }.bind(this))
            });

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?