Getting multiple value using the same Check Box name.
by kalai[ Edit ] 2008-03-11 12:01:27
For example when a form contains multiple checkboxes with the same name, multiple input an be retrieved using the following PHP code.
<?php
$str="";
if(isset($sub)){
$count=count($ckbox);
for($i=0;$i<$count;$i++)
{
$str="$str"."$ckbox[$i] ";
}
}
?>
<form name="frm" method="post" action="">
<input type="checkbox" name="ckbox[]" value="Java">
Java
<input type="checkbox" name="ckbox[]" value="PHP">
PHP
<input type="checkbox" name="ckbox[]" value="ASP">
ASP
<input type="checkbox" name="ckbox[]" value=".NET">
.NET
<input type="checkbox" name="ckbox[]" value="JavaScript">
JavaScript<br>
<input type="submit" name="Submit" value="Submit"><br>
<input name="sub" type="hidden" value="true">
Your selected field: <?php echo $str; ?>
</form>