Getting multiple value using the same Check Box name

Getting multiple value using the same Check Box name

For example when a form contains multiple checkboxes with the same name, multiple input an be retrieved using the following PHP code.

Sample PHP Code

<?php

$strExpert=”";

if(isset($hidSubmit)){

$count=count($chkexpert);

for($i=0;$i<$count;$i++){$strExpert=”$strExpert$chkexpert[$i], “;}

}

?>

Sample HTML Code for the above example

<form name=”form1″ method=”post” action=”"> <table width=”100%” border=”0″>

<form name=”form1″ method=”post” action=”"> <table width=”100%” border=”0″><tr><td>Your are Expertise field: </td></tr>

<tr>

<td><input type=”checkbox” name=”chkexpert[]” value=”PHP”>PHP

<input type=”checkbox” name=”chkexpert[]” value=”.NET”>.NET

<input type=”checkbox” name=”chkexpert[]” value=”Java”>Java</td>

</tr>

<tr>

<td><input type=”submit” name=”Submit” value=”Submit”>

<input name=”hidSubmit” type=”hidden” id=”hidSubmit2″ value=”true”></td>

</tr>

<tr>

<td><p>Result:</p>

Your Expertise field: <?php echo $strExpert; ?></td></tr>

</table>

</form>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.