469,646 Members | 1,173 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

getting at <input type=image ...> coordinates

When I click on the image form element
<INPUT type=image name=point src="map.png">
point.x and point.y values get submitted to the server
specifying where on the image I have clicked.

Is there any (simple) way to get ahold of that point.x and
point.y BEFORE they are sent to the server (and prevent
that from happening)? Ie. I just want the points where
someone clicks on an image and not interested in a submission
to the server.

Thanks,
Csaba Gabor
Jul 20 '05 #1
3 7443
What are you trying to do exactly? What do you plan to do with the x and y
values? Would an imagemap on the image not suffice?

Let us know.
Stu
Jul 20 '05 #2
Hi Stu. I want to mark two points on a map (so I can zoom in to a
subportion,
or not zoom, but select all the interesting items). So I'd like to get the
coordinates
first and just stuff them into some edit fields so the user can adjust them.
Also, having written a poor man's immediate fix version below that only
works
for IE, I can see that I'll also want to have the current position show in a
div.

My current hack:
<input type=image name=mymap onclick="return mapClick();">

and the script does:
function mapClick() {
document.forms[0]['pt'].value = Array(event.offsetX,event.offsetY);
return false;
}
I'm interested in the original question on a theoretical basis, but my
immediate interest is more practical in that the app is for my own editing
purposes.
I suspect you're correct that there are other ways to do this, and I'd
love to hear - my current knowledge of images/maps could stand bolstering.
I'm not sure I understand how to capture mouse coordinates with a
client side image map, though.

Csaba

"Stuart Palmer" <tr**********@youcant.com> wrote in message
news:2i************@uni-berlin.de...
What are you trying to do exactly? What do you plan to do with the x and y
values? Would an imagemap on the image not suffice?

Let us know.
Stu

Jul 20 '05 #3
"Csaba Gabor" <Cs***@z6.com> wrote:
Hi Stu.
Please spend some time in learning how to post to Usenet:
http://www.cs.tut.fi/~jkorpela/usenet/dont.html
Followups trimmed. Since you question was about JavaScript, not HTML, you
should have posted to the JavaScript group only.
I want to mark two points on a map (so I can zoom in to a
subportion,
Actually, I think you probably need a server-side script
My current hack:
<input type=image name=mymap onclick="return mapClick();">

and the script does:
function mapClick() {
document.forms[0]['pt'].value =
Array(event.offsetX,event.offsetY); return false;
}
So you had the answer, but you didn't bother telling it in the original
question.
I'm interested in the original question on a theoretical basis,
What question? Your JavaScript code prevents form submission when the
image is clicked on, provided that JavaScript is enabled. What "theory"
do you need in addition to that? Did you seriously expect to be able to
do such things in HTML, or what?

If you are unhappy with your own solution, consider explaining what is
your problem with it.
my immediate interest is more practical in that the app is for my own
editing purposes.


So it didn't really belong to comp.infosystems.www.authoring.* at all.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Martin Lucas-Smith | last post: by
5 posts views Thread by Jonathan Daggar | last post: by
2 posts views Thread by Richard Maher | last post: by
2 posts views Thread by jp2code | last post: by
1 post views Thread by test9991014 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.