HI
Thnx for ur response
this thing know already i asked if i select 3 checkboxes on the first page then how to access all those three selected check boxes the method u gave print only the last selected box
if u know then plz reply
bye
This sample is incorrect! It treats the checkboxes like radio buttons because you give them all an identical name. And only
one of the names can be set that way. When you want to get all the values that have been checked, you make the name field an array. So when you click checkboxes 1 and 3 (values 'a' and 'c'), you have an array that, when printed using print_r looks like:
- Array (
-
[0] => a
-
[1] => c
-
)
So in your catching script you must process the array with name $_POST['checkbox']
Here is the code:
[php]<body>
<form action="checkbox.php" method="post">
<input type="checkbox" name="checkbox[]" value="a">
<input type="checkbox" name="checkbox[]" value="b">
<input type="checkbox" name="checkbox[]" value="c">
<input type="checkbox" name="checkbox[]" value="d">
<br>
<br>
<input type="submit" name="Submit" value="Submit">
</form>
<?
/* and in your checkbox.php you do this: */
if(isset($_POST['Submit']))
{
for ($i=0; $i<count($_POST['checkbox']);$i++) {
echo "<br />value $i = ".$_POST['checkbox'][$i];
}
}
?>
</body>
[/php]
When you select boxes 2 and 4, the result of this script is then
Ronald :cool: