동의 체크시 값 채택완료
망이망소이
7년 전
조회 1,790
아래는 회원가입시 약관 동의 페이지의 부분인데요
한번에 체크하는 부분을 적용한 것입니다.
잘 작동하는데 문제는
저장되고나서 수정할때 보면 선택한 것을 체크상태로 가지고 있질 못하던데
실제 회원정보보면 동의 한것은 보이구요.
스크립트에서 클릭시 value값을 넣어줘야 되나요?
조언 부탁드립니다.
</p>
<p>//동의1</p>
<p><fieldset class="fregister_agree">
<input type="checkbox" name="agree" value="1" id="agree11">
<label for="agree11" style="color:#ccc;"> 읽었으며 이에 동의합니다.</label>
</fieldset>
//동의2</p>
<p><fieldset class="fregister_agree">
<input type="checkbox" name="agree2" value="1" id="agree21">
<label for="agree21" style="color:#ccc;"> 읽었으며 이에 동의합니다.</label>
</fieldset></p>
<p> </p>
<p>//모두동의
<div id="fregister_chkall" style="float:left;">
<input type="checkbox" name="chk_all" value="1" id="chk_all">
<label for="chk_all">위 내용들에 모두 동의합니다.</label>
</div>
</p>
<p> </p>
<p>//스크립트</p>
<p>jQuery(function($){
// all
$("input[name=chk_all]").click(function() {
if ($(this).prop('checked')) {
$("input[name^=agree]").prop('checked', true);
$("input[name^=agree]+label").css('color', '#777');
} else {
$("input[name^=agree]").prop("checked", false);
$("input[name^=agree]+label").css('color', '#ccc');
}
});
// name=agree
$("input[name=agree]").click(function() {
if ($(this).prop('checked')) {
$("input[name=agree]").prop('checked', true);
$("input[name=agree]+label").css('color', '#777');
} else {
$("input[name=agree]").prop("checked", false);
$("input[name=agree]+label").css('color', '#ccc');
}
});
// name=agree2
$("input[name=agree2]").click(function() {
if ($(this).prop('checked')) {
$("input[name=agree2]").prop('checked', true);
$("input[name=agree2]+label").css('color', '#777');
} else {
$("input[name=agree2]").prop("checked", false);
$("input[name=agree2]+label").css('color', '#ccc');
}
});
});
</p>
<p>
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
채택된 답변
+20 포인트
7년 전
무슨말인지 잘모르겠습니다..
회원가입동의부분은 수정시에 보일이유가 없지않나요..?
수정시 만약 회원이 동의했다는걸 표시하기위해서는 해당값을 가져와서 checked해주는게 필요하긴한데
수정할때 회원약관동의부분이 필요한가요..?
로그인 후 평가할 수 있습니다
답변에 대한 댓글 3개
�
망이망소이
7년 전
P
Policia
7년 전
아하 그러면 메일수신동의체크부분이 안된다는거네요
그누보드시라면 get_checked('필드값', '확인값')이란 함수가있어서 이걸 사용하시거나
아니시면
<input name="agree" <?php echo ($row['agree']==1)? 'checked' : ''; ?>> 이런식으로 쓰시면 될듯합니다 물론 $row['agree']부분은 임의로 넣은것이기때문에 호출변수에 맞는걸로 사용하시면됩니다
그누보드시라면 get_checked('필드값', '확인값')이란 함수가있어서 이걸 사용하시거나
아니시면
<input name="agree" <?php echo ($row['agree']==1)? 'checked' : ''; ?>> 이런식으로 쓰시면 될듯합니다 물론 $row['agree']부분은 임의로 넣은것이기때문에 호출변수에 맞는걸로 사용하시면됩니다
�
망이망소이
7년 전
Polica님 말씀대로
<?php echo ($w=='' || $member['mb_mailling'] || $row['agree']==1)? 'checked':''; ?>>
요렇게 체크하나 더 넣으니 됩니다 ^^ 감사합니다.
<?php echo ($w=='' || $member['mb_mailling'] || $row['agree']==1)? 'checked':''; ?>>
요렇게 체크하나 더 넣으니 됩니다 ^^ 감사합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
똑같은 소스를 회원정보입력 하단에 메일수신동의 등에 적용해놔서
질문을 위해 소스를 보인다는게 가입쪽 소스를 올려놨네요 ^^