Message rearranged because of jepoardy style posting...
Kurtis wrote:----- Original Message ----- From: "aman cgiperl" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, November 06, 2002 6:42 PM Subject: fetch data from having multiple <input type=image>I have a form that looks like this <form action="fetch.cgi" method=post> <input type=hidden name=xyz value=abc> <input type=image src="/file/path/aaaa.jpg name=aaa> <input type=image src="/file/path/bbbb.jpg name=bbb> </form> When I click on one of the images, the hidden value of xyz get carried How can I determine whether img name aaa or bbb was clicked? Thanks alot
> You can try JavaScript......................
>
> Replace the image from an INPUT type to an HREF and get rid of the form.
>
> Within the href of each image put this..............
>
> href="javascript: go_to('fetch.cgi?xyz=abc;image=aaa')"
> href="javascript: go_to('fetch.cgi?xyz=abc;image=bbb')"
>
Which isnt very portable.
If you have the form below: (notice the quotes around the value of the src attribute, they are missing in the above snippet)
<form action="fetch.cgi" method=post>
<input type=hidden name=xyz value=abc>
<input type=image src="/file/path/aaaa.jpg" name=aaa>
<input type=image src="/file/path/bbbb.jpg" name=bbb>
</form>
and the user clicks on the image that has its name attribute set to "bbb" then: "param('bbb.x')" and "param('bbb.y')" will return the x and y locations of where the mouse was clicked. So I might do something like this:
if ( param('aaa.x') or param('aaa.y') ) {
# user clicked on aaaa.jpg
} elsif ( param('bbb.x') or param('bbb.y') ) {
# user clicked on bbbb.jpg
}
note this will break if the user happens to click on pixel (0,0)
The above method is better than the javascript because its been standard html since 1.0 (I believe).
This is only a suggestion because I have only used an image as a submit button once, and that was awhile ago. Read up on it, as there may be even better solutions.
Below is some documentation I found at http://www.htmlhelp.com/reference/html40/forms/input.html
The image input type specifies a graphical submit button. The SRC attribute must be included to specify the URI of the image. The ALT attribute should be used to give replacement text for those not loading images. ALT is a new addition in HTML 4.0; many browsers rely on either the NAME or VALUE attribute as alternate text, so authors should use all three attributes for the same purpose where possible. The topic of graphical submit buttons for text users is discussed in detail in the article INPUT TYPE=IMAGE for text users?.
When the graphical submit button is clicked, the coordinates of the click are sent with the form submission as name.x=x-value and name.y=y-value where name is the value of the NAME attribute, x-value is the click's pixels from the left of the image, and y-value is the click's pixels from the top of the image. The USEMAP attribute combined with TYPE=image defines a client-side image map that can be used with client-side scripting, but this method is poorly supported. The USEMAP attribute gives the URI of the defining MAP.
Todd W.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]