리스트 에서 전체선택하면
넘어오는 데이터가 ["on", "1234","1235"]
위와 같이 데이터가 넘어옵니다.
on 만 빼고 나머지 idx 번호만 넘길 려면 어떻에 해야되나요?
조언 부탁드립니다.
|
답변 2개 / 댓글 2개
채택된 답변
+20 포인트
2015-04-13 (월) 15:05:23
주신 질문으로는 답변 자체가 좀 어렵겠네요.
전체 선택이라고 된 체크박스에는 value를 빼고 전송해 보세요.
html도 없고 js도 없어서 답변이 어렵네요.
답변에 대한 댓글 1개
sukja
2015-04-15 (수) 12:52:04
왕계란 님 감사합니다.
배열 함수 가지고 해결 했습니다.
무조건 전체 선택 할때 첫번재 배열을 시프트 하는 배열 함수로 해결 했습니다.
전체 선택 하고 아니고는 이것으로 했습니다.
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개
2015-04-15 (수) 13:05:36
[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]
이렇게 하셔도 됩니다.
답변을 작성하려면 로그인이 필요합니다.