infolink

Wednesday, 25 February 2015

PHP Multiple Checkbox Array

This example shows how the programmer can use multiple checkbox array and display the values of selected checkboxes.

Multiple Checkbox Array
Multiple Checkbox Array

PHP Code:

<form method='post' id='form1' action='CheckboxArray.php?process'> 
<table> 
<tr>
    <td>Checkbox Array Example. Select from below</td>
</tr>
<tr>
    <td>
    <input type='checkbox' name='checkboxarray[]' value='checkbox 1'>checkbox 1<br>
    <input type='checkbox' name='checkboxarray[]' value='checkbox 2'>checkbox 2<br>
    <input type='checkbox' name='checkboxarray[]' value='checkbox 3'>checkbox 3
    </td> 
</tr> 
</table> 
<input type='submit' id="submit" value="Click"> 
</form>

<?php 
if (isset($_GET['process'])) 
{
echo "you Selected: ";
foreach($_POST['checkboxarray'] as $value)
{
echo $value."\t"; 
}
}
?>


Note:

Copy and paste this code and save the file with the name of "CheckboxArray.php" and enjoyed.

OUTPUT


Multiple Checkbox Array
Multiple Checkbox Array

No comments:

Post a Comment