1. checkbox 전체 선택/해제 javascript
<script type="text/javascript">
function checkAll() {
var obj = document.frm;
for(var i=0; i<obj.checkbox.length; i++) {
obj.checkbox[i].checked = obj.chkAll.checked;
}
}
</script>
…
<form name="frm" action="recv.php" method="post">
<input type="checkbox" name="chkAll" onClick="javascript:checkAll();" />전체<br />
<input type="checkbox" name="checkbox[]" id="checkbox" value="7177207" />1<br />
<input type="checkbox" name="checkbox[]" id="checkbox" value="7178036" />2<br />
<input type="checkbox" name="checkbox[]" id="checkbox" value="7177374" />3<br />
<input type="button" value="눌러" onClick="document.frm.submit();" />
</form>
2. 다수 checkbox 체크 유무에 따른 value를 POST로 전달
$chkvalue = $_POST[checkbox];
$cnt = count($chkvalue);
$in_str = implode(",", $chkvalue);
$result = selectAll("_memo", "*", "where idx IN($in_str)");
Note
체크된 checkbox의 value들을 DB에서 select하는 예제이다.
'코딩 > PHP' 카테고리의 다른 글
Fatal error: Allowed memory size of xxx bytes exhausted (0) | 2012.11.08 |
---|---|
php와 mssql 서버 연결 (0) | 2012.08.13 |
Maximum execution time of 30 seconds exceeded (0) | 2012.05.10 |
curl - GET/POST method로 URL 호출 (0) | 2012.01.17 |
Open Flash Chart + PHP (0) | 2011.12.23 |