SSamTure.net

워드프레스

php에서 다중 선택된 체크박스 값 넘기기

[html]

<script type="text/javascript">
<!–
function checkForm(frm){

var chkbox = frm[‘chkbox[]’];
var cnt = 0;

for (var i = 0 ; i < chkbox.length; i++) {
if (chkbox[i].checked) {
cnt++;
}
}

if(cnt == 0){
window.alert("선택된 체크박스가 없음");
return;
}

document.frmList.action = "checkbox_ok.php";
document.frmList.submit();
}

</script>

<form name="frmList" method="POST" action="javascript:checkForm(document.frmList);">
<table>
<tr>
<td>선택</td>
<td >번호</td>
</tr>
<?php

for($i=0; $i<6; $i++){?>
<tr>
<td><input type="checkbox" name="chkbox[]" value="<?=$i?>" /></td>
<td><?=$i?></td>
</tr>
<?php }?>
<tr>
<td><input type="submit" name="Submit" value="전송" /></td>
</tr>
</table>
</form>

[/html]

Leave a Reply

Your email address will not be published. Required fields are marked *