Re: image button problem
| From: | CPT John W. Holmes | Date: | Tue, 12 Aug 2003 14:59:35 +0000 |
| Subject: | Re: image button problem | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-159284@lists.php.net to get a copy of this message | ||
From: "Abdul-wahid Paterson" <aw@lintrix.net>
>> What do you mean you don't know what button was pressed? You have
'test_x'
>> and 'test_y' so you know the "test" button was pressed. If you give the
>> other buttons a different name, you'll have different _x and _y variable
>> names, so you can still tell which one was pressed.
> Yes, I should have specified more accurately. I have quite a few of
> these buttons on one page (approx 30) and really wanted to have the same
> name="" for each one and only the value change. The reasoning for that
> is most parts of the page are generated from cached content due to heavy
> processing requirements on making the whole page.
>
> It is therefore quite difficult for me to change it to something like a
> series of name="test1" and name="test2" for all the buttons as the form
> being POST'd to would have a hard job trying to work out which names
> were valid for the POSTing form.
Diffucult? bah...
<form method="GET" action="page.php">
<input type="image" name="image[button1]" src="pic.gif">
<input type="image" name="image[button2]" src="pic.gif">
<input type="image" name="image[button3]" src="pic.gif">
</form>
Then, on page.php, to figure out what button was chosen, you simply use:
$button = each($_GET['image']);
Now, $button[0] or $button['key'] (whichever you want to use) will have one
of the values of "button1", "button2", or "button3" from your form.
Adapt to your needs.
---John Holmes...