Mi Lugarcito

CheckBox - 체크박스 선택시 div 나타나게 하기 본문

JavaScript

CheckBox - 체크박스 선택시 div 나타나게 하기

selene park 2021. 9. 5. 19:35
 <div class="panel-body">
                <div class="panel">
                    <div class="panel-heading">
                        <h5>판매할 가격 선택</h5>
                    </div>
                    <div class="panel-body" style="margin-bottom: 20px">
                        <div class="form-check">
                            <div class="list-group-item-checkbox toggleCheck">
                                @php
                                    $types = array(
                                        'is_month' => '월세',
                                        'is_rental' => '전세',
                                        'is_sale' => '매매',
                                    );
                                @endphp
                                @foreach($types as $key => $val)
                                    <label class="xe-label">
                                        <input type="checkbox" class="__xe_checkbox" name="{{$config->get('id')}}_{{$key}}" value="Y" data-target="{{$key}}" />
                                        <span class="xe-input-helper"></span>
                                        <span class="xe-label-text">{{$val}}</span>
                                    </label>
                                @endforeach
                            </div>
                        </div>
                    </div>
                </div>
                <div id="is_month" class="panel d-none">
                    <div class="panel-heading">
                        <h5>월세정보</h5>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-6 col-xs-6">
                                <label>월세 보증금</label>
                                <div class="input-group">
                                    <input type="text" class="mt-0 form-control filter-input" id="{{$config->get('id')}}_m_deposit" name="{{$config->get('id')}}_m_deposit" value="" />
                                    <div class="input-group-append">
                                        <span class="input-group-text" id="basic-addon2">만원</span>
                                    </div>
                                </div>
                            </div>
                            <div class="col-6 col-xs-6">
                                <label>월 임대료</label>
                                <div class="input-group">
                                    <input type="text" class="mt-0 form-control filter-input" name="{{$config->get('id')}}_m_price" value="" />
                                    <div class="input-group-append">
                                        <span class="input-group-text" id="basic-addon2">만원</span>
                                    </div>
                                </div>
                            </div>
                            <div class="col-6 col-xs-6">
                                <label>월세 관리비</label>
                                <div class="input-group">
                                    <input type="text" class="mt-0 form-control filter-input" name="{{$config->get('id')}}_m_expenses" value="" />
                                    <div class="input-group-append">
                                        <span class="input-group-text" id="basic-addon2">만원</span>
                                    </div>
                                </div>
                            </div>
                            <div class="col-6 col-xs-6">
                                <label>관리비 포함 여부</label>
                                <select class="form-control nice-select filter-input" name="{{$config->get('id')}}_m_in_expenses">
                                    <option value="N">미포함</option>
                                    <option value="Y">포함</option>
                                    <option value="E">금액미정</option>
                                </select>
                            </div>
                        </div>
                    </div> <!--// End panel-body-->
                </div> <!--// End Panel-->
                <div id="is_rental" class="panel d-none">
                    <div class="panel-heading">
                        <h5>전세정보</h5>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-6 col-xs-6">
                                <label>전세 보증금</label>
                                <div class="input-group">
                                    <input type="text" class="mt-0 form-control filter-input" name="{{$config->get('id')}}_r_deposit" value="" />
                                    <div class="input-group-append">
                                        <span class="input-group-text" id="basic-addon2">만원</span>
                                    </div>
                                </div>
                            </div>
                            <div class="col-6 col-xs-6">
                                <label>전세 관리비</label>
                                <div class="input-group">
                                    <input type="text" class="mt-0 form-control filter-input" name="{{$config->get('id')}}_r_expenses" value="" />
                                    <div class="input-group-append">
                                        <span class="input-group-text" id="basic-addon2">만원</span>
                                    </div>
                                </div>
                            </div>
                            <div class="col-6 col-xs-6">
                                <label>관리비 고정금액 여부</label>
                                <select class="form-control nice-select filter-input" name="{{$config->get('id')}}_r_in_expenses">
                                    <option value="N">금액고정</option>
                                    <option value="Y">별도산출</option>
                                    <option value="E">금액미정</option>
                                </select>
                            </div>
                        </div>
                    </div> <!--// End panel-body-->
                </div> <!--// End Panel-->
                <div id="is_sale" class="panel d-none" style="margin-top: 20px">
                    <div class="panel-heading">
                        <h5>매매정보</h5>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-6 col-xs-6">
                                <label>매매가</label>
                                <div class="input-group">
                                    <input type="text" class="mt-0 form-control filter-input" name="{{$config->get('id')}}_s_price" value="" />
                                    <div class="input-group-append">
                                        <span class="input-group-text" id="basic-addon2">만원</span>
                                    </div>
                                </div>
                            </div>
                            <div class="col-6 col-xs-6">
                                <label>포함된 융자금액</label>
                                <div class="input-group">
                                    <input type="text" class="mt-0 form-control filter-input" name="{{$config->get('id')}}_s_loan" value="" />
                                    <div class="input-group-append">
                                        <span class="input-group-text" id="basic-addon2">만원</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div> <!--// End panel-body-->
                </div> <!--// End Panel-->
            </div>

 

 

//매물가격 CheckBox show & non-show 
jQuery(document).ready(function($){
  $(".toggleCheck").find("input[type=checkbox]").click(function(){
    if($(this).is(":checked")){
      $("#" + $(this).attr('data-target')).removeClass('d-none');
    }else{
      $("#" + $(this).attr('data-target')).addClass('d-none');
    }
  });
});