2014-04-10 2 views
0

show = true (show = Boolean 유형) 인 경우 파일 업로드를 사용하도록 설정하면 확인란이 선택되어 있지 않으므로 기본적으로이 확인란을 선택하지 않고 파일 업로드를 사용하지 않도록 설정합니다. 내가 어떻게 할 수 있니? 작동하지 않는 사용/사용 안 함을 클릭하면 잘 작동하지 않는 다음 코드를 시도합니다.확인란이 참일 때 파일 업로드 가능

$(function() { 
    $("#show").change(function() { 
     $("#fileUpload").toggle(this.checked).prop("disabled", false); 
    }); 
}); 
$("#fileUpload").toggle(this.checked).prop("disabled", true); 




<div class="form-group"> 
    @Html.LabelFor(model => model.show, new { @class = "control-label col-md-2" }) 
    <div class="col-md-10"> 
     @Html.EditorFor(model => model.show) 
     @Html.ValidationMessageFor(model => model.show) 
    </div> 
</div> 


    <div class="form-group"> 

     @Html.LabelFor(model => model.File, new { @class = "control-label col-md-2" }) 
     <div class="col-md-10"> 
      <input type="file" id="fileUpload"/> 
     </div> 
    </div> 

답변

0

왜 체크 박스가 선택 될 때까지 파일 업로드를 숨기지 않으시겠습니까? 이 바이올린 같은

$(document).ready(function(){ 
    $('#uploads').hide(); 
    $('#enable_uploads').change(function(){ 
     $('#uploads').toggle() 
    }); 
}); 

: http://jsfiddle.net/E3PHP/

관련 문제