카테고리와 if문 질문입니다.

카테고리와 if문 질문입니다.

QA

카테고리와 if문 질문입니다.

본문

	
<?php if ( $notice_checked != 'checked') {?>
            <?php if ($is_category) { ?>
            <tr>
                <th scope="row"><label for="ca_name">분류<strong class="sound_only">필수</strong></label></th>
                <td class="border_r0">
                    <select name="ca_name" id="ca_name" required class="required form-control input_type1" >
                        <option value="">업무종류를 선택하세요</option>
                        <?php echo $category_option ?>
                    </select>
                </td>
            </tr>
            <?php } ?>

			<?php } else {?>
			 <tr>
                <th scope="row"><label for="ca_name">분류<strong class="sound_only">필수</strong></label></th>
                <td class="border_r0">
                    <select name="ca_name" id="ca_name" required class="required form-control input_type1" >
                        <option value="공지">공지</option>
                    </select>
                </td>
            </tr>
			<?php } ?>

write.skin.php에서

공지사항 체크를 하면 분류내용이 실시간으로 바뀌도록 하고싶은데요


공지사항을 체크하면 a셀렉트가 나오게

공지사항을 체크하지 않으면 b셀렉트가 나오게요,,


문법이 모가 틀렸나요? ㅠㅠ

이 질문에 댓글 쓰기 :

답변 2

글 작성시, 공지사항 체크박스 체크 여부에 따라 다른 분류의 셀렉트박스가 나오게 하는 것은


자바스크립트로 처리해야 하는 성격입니다.


(sample)

<script>
$(function() {	
	$('select[name=sel_temp1]').attr('name', 'ca_name');
	$('select[name=sel_temp1]').show();
	
	$('select[name=sel_temp2]').attr('name', 'sel_temp2');
	$('select[name=sel_temp2]').hide();		
	
	$('checkbox[name=is_notice]').on('change', function() {
		if($(this).is(":checked")) {         
			$('select[name=sel_temp1]').attr('name', 'ca_name');
			$('select[name=sel_temp1]').show();
			
			$('select[name=sel_temp2]').attr('name', 'sel_temp2');
			$('select[name=sel_temp2]').hide();		
    } else {
    	$('select[name=sel_temp1]').attr('name', 'sel_temp1');
			$('select[name=sel_temp1]').hide();
			
			$('select[name=sel_temp2]').attr('name', 'ca_name');
			$('select[name=sel_temp2]').show();			    	
    }
	});		    	
});
</script>
<input type="checkbox" name="is_notice" value="1" /> 공지
<br>
<select name="sel_temp1">
	<option>분류1</option>
	<option>분류2</option>
</option>
</select>
<select name="sel_temp2">
	<option>분류1</option>
	<option>분류2</option>
</option>
</select>



샘플 코드에 잘못된 부분이 있었네요.

수정된 샘플 코드입니다.


<script>
$(function() {
	$('#sel1').attr('name', 'ca_name');
	$('#sel1').show();

	$('#sel2').attr('name', 'sel_temp2');
	$('#sel2').hide();

	$('input[name=is_notice]').on('change', function() {
		if($(this).is(":checked")) {
			$('#sel1').attr('name', 'sel_temp1');
			$('#sel1').hide();

			$('#sel2').attr('name', 'ca_name');
			$('#sel2').show();
		} else {
			$('#sel1').attr('name', 'ca_name');
			$('#sel1').show();

			$('#sel2').attr('name', 'sel_temp2');
			$('#sel2').hide();
		}
	});
});
</script>
<input type="checkbox" name="is_notice" value="1" /> 공지
<br>
<select id="sel1" name="sel_temp1">
	<option>분류1</option>
	<option>분류2</option>
</select>
<select id="sel2" name="sel_temp1">
	<option>분류3</option>
	<option>분류4</option>
</select>

동적인 부분은 제이쿼리로 처리하셔야합니다.

답변을 작성하시기 전에 로그인 해주세요.
전체 97
QA 내용 검색
filter #if ×

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT