views:

972

answers:

3

I know it can be done and I even have a vague idea of how to do it but it stops at being vague.

I have a standard HTML image tag with an image in it, 100 by 100 pixels in size. I want people to be able to click the image and for that to pass the X and Y that they click into a function.

The coordinates need to be relative to the image top and left.

Thank you in advance for any help.

+2  A: 

I think you're talking about:

<input id="info" type="image">

When submitted, there are form values for the x and y coordinate based on the input element id (info.x and info.y in this case).

http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4.1

Jon Galloway
+5  A: 

This thread answers exactly the same question

With more info here

Pat
A: 

from what you describe you should register to the image mouse event, for this case you should have the image mouse button event.

at the function you should use

Point mousePoint = e.GetPosition( this );

that will give you the mouse position according to the top left point int pixels.

than at the "mousePoint" you can print the X and Y information.

Omer Aviad