A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearIs it possible to get the image mouse click location with PHP? - page 1
User InfoPosts
Is it possible to get the image mouse click location with PHP?#1
Basically what the title says...

I need to have an image that when clicked, I call script.php for instance and in that PHP script file, I get the image coordinates where the mouse was clicked.

Is this possible?

EDIT:
After a couple of answers I realized I didn't describe my problem correctly... The thing is, I don't have total control over the HTML. The control I have for the image and the image link is the control BBCode provides me.

Basically want I want to do is to have a forum signature with links to various sections on my website. You could argue I could use multiple images but most forums limit how much you can type for the signature, which is not enough for multiple images.

So, I will only be able to do something like this:

[url=http://www.mydomain.com/script.php]
[img]http://www.mydomain.com/signature.jpg[/img]
[/url]


Which translates to something like this:

<a href="http://www.mydomain.com/script.php">
<img src="http://www.mydomain.com/signature.jpg" />
</a>

posted date: 2008-12-10 19:41:00


Re: Is it possible to get the image mouse click location with PHP?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-10 19:41:01


Re: Is it possible to get the image mouse click location with PHP?#3
If you use an input type="image", which works like a button, it will send you x and y coordinates of the mouse click (submits form too).More info here: http://www.htmlhelp.com/reference/html40/forms/input.html#imageLong time since I used it, but I did make it work for a "where's the ball?" competition on a site many years ago.Update: Sounds like the environment is just too limited to do what you want. If the forum lets you do an image map that would work, but I doubt they'd let you. Only other things I could think of would be flash or javascript, similarly, they prob won't allow them. You need something with a little more smarts than an image and an anchor to make this work.

posted date: 2008-12-10 19:47:00


Re: Is it possible to get the image mouse click location with PHP?#4
if you set the image input name="foo", then $\_POST['foo\_x'] and $\_POST['foo\_y'] will be set to the image coordinates.

posted date: 2008-12-10 19:52:00


Re: Is it possible to get the image mouse click location with PHP?#5
You can use an ajax request when "onclick" is performed to send a request to "script.php". Otherwise I would read up on php, which is a server-side language.

posted date: 2008-12-10 20:32:00


Re: Is it possible to get the image mouse click location with PHP?#6
I can't do that :( I just updated my post with more info on my problem.

posted date: 2008-12-10 20:42:00


Re: Is it possible to get the image mouse click location with PHP?#7
I tried that for the <img> tag but it didn't work. But I suppose that your suggestion was something in the lines of seanb's answer? If so, the same info on my updated post also applies.

posted date: 2008-12-10 20:44:00


Re: Is it possible to get the image mouse click location with PHP?#8
Check my updated post, can't use ajax at all.

posted date: 2008-12-10 20:45:00


Re: Is it possible to get the image mouse click location with PHP?#9
This will not be possible unless you can add inline event handlers to the url in bbcode.

posted date: 2008-12-10 20:50:00


Re: Is it possible to get the image mouse click location with PHP?#10
If you can't:use JavaScript, oruse input type="image", oradd any attributes to your img tag (to do things like create an image map)then, no, you won't be able to do what you describe.

posted date: 2008-12-10 21:01:00


Re: Is it possible to get the image mouse click location with PHP?#11
You could try using W3C Image MapsImage maps allow authors to specify regions of an image or object and assign a specific action to each region (e.g., retrieve a document, run a program, etc.) When the region is activated by the user, the action is executed.But on a forum in BBCode, I really don't think you're going to be able to get what you're after.

posted date: 2008-12-10 21:12:00


Re: Is it possible to get the image mouse click location with PHP?#12
Another solution, though not for BBCode is to use the ismap attribute for img. But may be valuable to others needing exact coordinates. Example:<a href="link.html"><img src="shapes.jpg" alt="Shapes" ismap="ismap"/></a>The x and y coordinates will be passed as GET parameters to link.html

posted date: 2008-12-10 21:34:00


select page: « 1 2 »
Copyright ©2008-2017 www.momige.com, all rights reserved.