SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP GD

Collecting the coordinates data inside of an image on click

Collecting the values of the coordinates of any image is a common requirement in many applications. For example if we have one map and wants the visitors to click on any area of the map to enlarge ( zoom ) it then we must know the coordinates of the click point where the visitor wants to be magnified. Based on the coordinates in X and Y plot of the image we can further process the script to give desire result. The example below will display the values of the coordinate ( X and Y ) of the point you click. Here by using CSS, your mouse pointer is changed to cross. You can learn more on how to change the mouse pointer in our CSS section or click here. Copy the code of this example given at the end. Note that the value of X ( horizontal ) and Y ( Vertical ) coordinate is zero at the top left corner of the image. It reaches its maximum value at the right bottom point of the image.

X=, Y=

          
Here is the code
<?Php
$foo_x=$_POST['foo_x'];
$foo_y=$_POST['foo_y'];
echo "X=$foo_x, Y=$foo_y ";
?>
<form action='' method=post>
<input type="image" alt=' Finding coordinates of an image' src="xy-coordinates.jpg" 
name="foo" style=cursor:crosshair;/>
</form>

Number of User Comments : 3


Google+
Paco21-08-2012
This was so helpful and saved me a lot of time. Thanks a lot.
Dennis15-10-2012
How would i use this method if i wanted to have 2 images that i want to click before the form posts?
Mary05-04-2013
it was so helpful! Thank you very much! ^_^
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer