JQUERY
jquery eq
nineDeveloper
2014. 6. 5. 13:15
728x90
반응형
<select name="check_result" class="check_result" id="check_result" onChange="disabledSetting()" > | <select name="problem_status" class="problem_status" id="problem_status" > | <input type="text" class="problem_description" id="problem_description" /> |
<반복> | <반복> | <반복> |
EL을 사용해서 위와 같은 내용을 표 형태로 뿌리고 check_result 셀렉트 박스를 선택함에 따라 problem_status와 problem_description의 상태를 row단위별로 disabled상태로 동적으로 변화시키고 싶었다..
그래서 jquery를 사용하였는데, 처음에는 div내의 class가 problem_status와 problem_description인 것을 모두 가져오는 방법을 썻지만 첫 번째 줄의 값만 가져왔다..
그러던 중 다음과 같은 jquery의 :eq(index) 를 이용해서 인덱스를 가져와서 선택하는 방법을 사용해서 성공하였다.
disabledSetting = function (){
for(var i=0; i<"${rBox.dailyCheckDetail.serviceCount}"; i++){
var check_yn =$('.board1').find('.check_result:eq('+i+')').val();
var status_setting = $('.board1').find('.problem_status:eq('+i+')').val();
var description_setting = $('.board1').find('.problem_description:eq('+i+')').val();
if(check_yn =='N' ){
$('.board1').find('.problem_status:eq('+i+')').removeAttr("disabled");
$('.board1').find('.problem_description:eq('+i+')').removeAttr("disabled");
}else{
$('.board1').find('.problem_status:eq('+i+')').attr("disabled",true);
$('.board1').find('.problem_description:eq('+i+')').attr("disabled",true);
}
}
};
jQuery API 사이트에 가보면 다음과 같이 소개되어 있다..
indexAn integer indicating the 0-based position of the element.
정수형 값을 넣으면 해당 숫자의 값을 가져올 수 있다.
<< 확인결과의 select box를 변화시키면 특이사항의 selectbox와 inputbox의 상태가 변한다..>>
728x90
반응형