Hi,

Why do you want a checkbox beside each button?  Wouldn't the button alone be
enough?  I'm assuming it's for something like a delete items list?

This is one of many ways to do it... I can't see why you need checkboxes --
perhaps you need to tell us more abut what you want to achieve.

<?
for($i=1;$i<=30;$i++)
    {
    echo "<form action='anyfile.php' method='post'>";
    echo "Delete Item # {$i} ";
    echo "<input type='hidden' name='item' value='{$i}' />";
    echo "<input type='submit' name='delete' value='go' />";
    echo "</form>";
    }
?>

This would create 30 go buttons, each one on it's own form, each one having
a hidden name/value of item/$i.  On anyfile.php you would be concerned with
the POST var $_POST['item'] (or $item if reg globals on), and perhaps
$_POST['delete'] to know that the form was submitted.


Another option might be a list of checkboxes, and ONE go button to delete
all checked items:

<form action='anyfile.php' method='post'>
<?
for($i=1;$i<=30;$i++)
    {
    echo "Item #{$i} ";
    echo "<input type='checkbox' name='delete[{$i}]' value='1' />";
    }
?>
<input type='submit' name='delete' value='delete checked items' />

On anyfile.php, you would have an array $_POST['delete'] that you could loop
through, getting the keys (id's of items to be deleted) and acting upon
them.


I could go on :)


Justin







on 11/02/03 12:09 PM, Vahldieck, Mike ([EMAIL PROTECTED]) wrote:

> Hi there,
> 
> I'm new to PHP, so maybe this Q makes me look rather stupid... never mind,
> asking it anyway...
> 
> I want to have a form with several checkboxes and an OK button next to each
> of them, to enable users to send data when checkbox has been changed..
> I need to pass $i to know, which button has been clicked...
> 
> for ($i = 1; $i <= 30; $i++) {
> echo "<INPUT TYPE=\"checkbox\" name=\"cbox$i\" checked>checkbox No. $i";
> echo "....";
> echo "<FORM ACTION=\"anyfile.php?box=$i\" METHOD=\"POST\">";
> echo "<INPUT TYPE=\"Submit\" NAME=\"OK$i\" VALUE=\"OK\">";
> echo "<br>";
> }
> ?>
> 
> 
> I always get anyfile.php?box=1 ... What am I doing wrong?
> Better ways to do that?
> 
> Thanks for your help
> greetings from Berlin/Germany
> Mike
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to