답변 2개
채택된 답변
+20 포인트
BiHon
3년 전
구현 방법은 다양한데 어차피 기타 선택 시 활성화 여부니까 아래처럼 간단하게 하면 되겠네요.
Copy
<label><input type="checkbox" name="name[]" value="기타" onclick="document.getElementById('etc').style.display=this.checked?'inline-block':'none';">기타</label>
<input type="text" name="etc" id="etc" value="" style="display:none;">
* id는 유일해야 합니다.
로그인 후 평가할 수 있습니다
답변에 대한 댓글 5개
BiHon
3년 전
BiHon
3년 전
[code]
<?php
$display_check = '';
$display_style = 'none';
if ( 기타체크여부 ) {
$display_check = ' checked';
$display_style = 'inline-block';
}
?>
<label><input type="checkbox" name="name[]" value="기타" onclick="document.getElementById('etc').style.display=this.checked?'inline-block':'none';"<?=$display_check?>>기타</label>
<input type="text" name="etc" id="etc" value="<?=$저장된값?>" style="display:<?=$display_style?>;">
[/code]
<?php
$display_check = '';
$display_style = 'none';
if ( 기타체크여부 ) {
$display_check = ' checked';
$display_style = 'inline-block';
}
?>
<label><input type="checkbox" name="name[]" value="기타" onclick="document.getElementById('etc').style.display=this.checked?'inline-block':'none';"<?=$display_check?>>기타</label>
<input type="text" name="etc" id="etc" value="<?=$저장된값?>" style="display:<?=$display_style?>;">
[/code]
두더지클럽
3년 전
말씀하신대로 해도 안됩니다.
입력하고 노출은 잘되는데.. 수정으로 들어가면 기존 입력된 내용은 없어요..
보시고 어디가 잘못된건지.. 알려주시면 고맙겠습니다.
[code] <div class="form-group row mb-0">
<label class="col-md-2 col-form-label" for="wr_20">기타항목</label>
<div class="col-md-10">
<label><input type="checkbox" name="wr_3" value="기타" onclick="document.getElementById('etc').style.display=this.checked?'inline-block':'none';"> 기타항목입력</label>
<input type="text" name="wr_3" id="etc" value="<?=$저장된값?>" style="display:none;">
</div>
</div>
<?php
$display_check = '';
$display_style = 'none';
if ( 기타체크여부 ) {
$display_check = ' checked';
$display_style = 'inline-block';
}
?>[/code]
입력하고 노출은 잘되는데.. 수정으로 들어가면 기존 입력된 내용은 없어요..
보시고 어디가 잘못된건지.. 알려주시면 고맙겠습니다.
[code] <div class="form-group row mb-0">
<label class="col-md-2 col-form-label" for="wr_20">기타항목</label>
<div class="col-md-10">
<label><input type="checkbox" name="wr_3" value="기타" onclick="document.getElementById('etc').style.display=this.checked?'inline-block':'none';"> 기타항목입력</label>
<input type="text" name="wr_3" id="etc" value="<?=$저장된값?>" style="display:none;">
</div>
</div>
<?php
$display_check = '';
$display_style = 'none';
if ( 기타체크여부 ) {
$display_check = ' checked';
$display_style = 'inline-block';
}
?>[/code]
댓글을 작성하려면 로그인이 필요합니다.
3년 전
그부분은 일단 div로 해서 묵어 두시고
<div class="etc_div" style="display:none">
<input type="radio">
</div>
제이쿼리로 열어주면되요
토글 아니면 show로 해주세요
$(function() {
$('.etc_div').click('click',function() {
$(this).toggle();
})
});
로그인 후 평가할 수 있습니다
답변에 대한 댓글 2개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
[code]
<?php
$display_check = '';
$display_style = 'none';
if ( 기타체크여부 ) {
$display_check = ' checked';
$display_style = 'inline-block';
}
?>
<label><input type="checkbox" name="name[]" value="기타" onclick="document.getElementById('etc').style.display=this.checked?'inline-block':'none';"<?=$display_check?>>기타</label>
<input type="text" name="etc" id="etc" value="" style="display:<?=$display_style?>;">
[/code]