Re: Multiple image buttons
| From: | CPT John W. Holmes | Date: | Tue, 09 Sep 2003 13:18:29 +0000 |
| Subject: | Re: Multiple image buttons | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-162059@lists.php.net to get a copy of this message | ||
From: "Hardik Doshi" <php_hardik@yahoo.com>
> I have a page on which there are multiple image
> buttons. Is there any way to determine which button is
> pressed by the user?
>
> For example, there is a page on which i display all
> the users of the system with the edit and delete
> button beside each user entry. Now if admin wants to
> delete one of the users then how can i know admin
> pressed which button? It is possible with non-image
> button but image button always give me x and y
> co-ordinates.
>
> Please let me know if you have any clue.
Use a method like this:
<html>
<form method="POST" action="test.php">
<input type="image" src="image.gif" name="image[1]">
<input type="image" src="image.gif" name="image[2]">
<input type="image" src="image.gif" name="image[3]">
<input type="image" src="image.gif" name="image[4]">
</form>
</html>
<?php
if(isset($_POST['image']))
{
$button = each($_POST['image']);
//$button['key'] will contain the number
//of the button that was clicked on
echo "You pressed button {$button['key']}";
}
?>
Where the number in image[XX] will user_id of the user you want to edit or
delete.
---John Holmes...