
December 27th, 2003
06:19 AM
looping checkbox values..
i have a form which has checkboxes. it looks something like:
<form action="../queries/entrymanage.php" method="POST">
<input type="checkbox" name="checkbox" value="1'">
<input type="checkbox" name="checkbox" value="2">
<input type="checkbox" name="checkbox" value="3">
<input type="submit" name="Submit" value="show selected">
</form>
and i'm having trouble figuring out how to loop the values of the "checked" checkboxes on the entrymanage.php page. yeah.. alright. any help is appreciated.

December 27th, 2003
08:15 AM
Neversidian
Status: Offline!
is this what you mean?
<form action="../queries/entrymanage.php" method="POST">
<?php
for($i=1$i<4;$i++){
echo '<input type="checkbox" name="checkbox[]" value="'.$i.'">';
}
?>
<input type="submit" name="Submit" value="show selected">
</form>
___________________
Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

December 27th, 2003
08:58 AM
here is an example of what I think you are asking:
page1:
<form name="theform" method="post" action="page2.html">
<input type="checkbox" name="val[]" value="line1">line1
<input type="checkbox" name="val[]" value="line2">line2
<input type="checkbox" name="val[]" value="line3">line3
<input type="checkbox" name="val[]" value="line4">line4
<br><br>
<input type="submit" name="submit" value="submit">
page2.html:
<?php
foreach($_POST['val'] as $selected) {
echo($selected);
}
?>

December 27th, 2003
09:37 AM
thank you BigToach and vvuiverine, i have it working now