Jump to content

I will pay anyone who can.... need X and Y cordinate of image


jonaofarc

Recommended Posts

I will pay anyone who can.... need X and Y cordinate of image that when user click image a text box opens in that spots and you can comment the image ..... I dont understand how to pass Javascript values into PHP anyways if anyone can help me get this done i will pay $20 via paypal. thanx!

What? Why do you need to pass the x and y to a PHP script?

 

Some questions. Will the text box open above the image, where they clicked, or will it open below or to the side of the image?

And is there more then 1 image on the page?

Ask in the javascript forum, because I have no clue. :P

That's a bit more advanced javascript then what I could do.

 

This might help:

http://www.emanueleferonato.com/2006/09/02/click-image-and-get-coordinates-with-javascript/

this should get you started

<?php 
if (isset($_GET['myimage_x']))                  
{
$imageX = $_GET['myimage_x'] ;              // if you click on a form image it sends the coords of the click 
$imageY = $_GET['myimage_y'] ;
}
else $imageX = $imageY = -1;

echo '<pre>', print_r($_GET, true), '</pre>';
?>
<html>
<head>
<meta name="generator" content="PhpED Version 4.5 (Build 4513)">
<title>Sample Image Comment</title>
<meta name="author" content="Barand">
<link rel="shortcut icon"  href="">
<script type='text/javascript'>
var clickX = <?php echo $imageX ?>;                            // store PHP vars in JS script
var clickY = <?php echo $imageY ?>;

function placeComment()
{
	if (clickX == -1) return;
	var pic = document.getElementById("myimage");
	var box = document.getElementById("comment");
	var ix = pic.offsetLeft;
	var iy = pic.offsetTop;
	box.style.position = "absolute";
	box.style.top = iy+clickY;                            // calc position in page
	box.style.left = ix+clickX;
}
</script>
</head>
<body onload = "placeComment()">
<form>
<input type='image' name='myimage' id='myimage' src='../baaWelcome.gif' border='0' width='596' height='52' ><br/>
<input type='text' name='comment' id='comment' value='Your comment' size='40' style='zIndex: 1'>
</form>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.