Forum Moderators: open

Message Too Old, No Replies

Sending coordinates of image automatically

through an image submit button

         

Dibermann

8:54 pm on Aug 12, 2006 (gmt 0)

10+ Year Member



Hi everyone,

i've been trying to solve this problem for the past couple of days. I have an image submit button so that when a user clicks the image the coordinates of the clicking are sent, ie, in a map i click on London and the coordinates of London are sent. What im trying to do now is sending the coordinates automatically through Javascript without clicking the image. i tryed to do document.forms[0].submit() but the coordinates it sends are (1,1). How can i send other coordinates through Javascript?

Thanks in advance

MisYu

2:43 pm on Aug 14, 2006 (gmt 0)

10+ Year Member



Need more information to help you, i.e.:
- do you have a <area> or just <input type="image">
- do you want to pass the pixel position of the clicked element (it's posLeft/posTop properties) or do you want to catch the exact position of mouse cursor whilst clicking? if the second option, then you'll have to work with events a bit, store all neccessary values into a hidden field and pass it to the server, in example:

<input type="hidden" id="secretHidden" value="" />
<input type="image" onclick="javascript:catchme(event);">

function catchme(evt)
{
if (!evt) var evt = window.event;
alert("Mouse X: " + evt.clientX + "\nMouse Y: " + evt.clientY);
document.getElementById("secretHidden").value = evt.clientX.concat(",") + evt.clientY;
}

Dibermann

11:52 am on Aug 15, 2006 (gmt 0)

10+ Year Member



- i have an <input type="image">, just like
<input src="image.gif" name="image_name" type="image">.

- i want to pass the coordinates (posLeft/posTop properties) automatically, without clicking the image. i have predefined coordinates where i want to go, so i dont need to click the image, just send the coordinates through javascript.