라디오 선택에 따라
본문
<label style="color:blue"><input type="radio" name="price" value="wr_1"> 수입</label>
<label style="color:red"><input type="radio" name="price" value="wr_2" checked> 지출 </label>
위의 수입선택하면 wr_1이 나타나고 wr_2는 hidden으로
, 지출 선택하면 wr_2가 나타나게 wr_1은 hidden으로 나타나게하고 싶습니다.
<input type="text" placeholder="수입금액" class="inpBox" name="wr_1" id="wr_1" value="<?php echo $write['wr_1'] ?>" >
<input type="text" placeholder="지출금액" class="inpBox" name="wr_2" id="wr_2" value="<?php echo $write['wr_2'] ?>" >
답변 2
$(function(){
$("input:radio[name=price]").click(function(){
chk = $(this).val();
$('.inpBox').hide(); $('#'+chk).show();
});
});
<script>
$("input:radio[name=price]").click(function(){
if($("input:radio[name=price]:checked").val()=='wr_1'){
$("#wr_1").attr("disabled",false);
$("#wr_1").removeClass("readonly");
} else {
$("#wr_2").attr("disabled",true);
$("#wr_2").addClass("readonly");
}
}); </script>
이렇게 하시면 될것 같은데.... 테스트는 안해봤습니다. ^.^ 참고하세요~!!
!-->
답변을 작성하시기 전에 로그인 해주세요.