답변 2개 / 댓글 2개
채택된 답변
+20 포인트
주신 질문으로는 답변 자체가 좀 어렵겠네요.
전체 선택이라고 된 체크박스에는 value를 빼고 전송해 보세요.
html도 없고 js도 없어서 답변이 어렵네요.
왕계란 님 감사합니다.
배열 함수 가지고 해결 했습니다.
무조건 전체 선택 할때 첫번재 배열을 시프트 하는 배열 함수로 해결 했습니다.
전체 선택 하고 아니고는 이것으로 했습니다.
http://sir.co.kr/bbs/board.php?bo_table=pg_tip&wr_id=13046
Copy
// 배열에 on이 포함 되어 있을때 제거$chk = $_POST['chkidx'];$fchk = $chk[0]; // 첫번째 배열을 무조건 가져와서// 조건 'on'이 있으면 on 제거 후 나머지 반영if ($fchk == on) { $stack = $_POST['chkidx'];$fruit = array_shift($stack);} else { $stack = $_POST['chkidx'];}
답변에 대한 댓글 1개
[code]
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(function() {
$("#chk").change(function () {
$("input[name='aa[]']").prop("checked", this.checked);
});
});
</script>
<input type="checkbox" id="chk" />check all<br />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
[/code]
이렇게 하셔도 됩니다.
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(function() {
$("#chk").change(function () {
$("input[name='aa[]']").prop("checked", this.checked);
});
});
</script>
<input type="checkbox" id="chk" />check all<br />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
<input type="checkbox" name="aa[]" />
[/code]
이렇게 하셔도 됩니다.
답변을 작성하려면 로그인이 필요합니다.