GetDotted Domains

Viewing Thread:
"Image Maps"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Sun 31/10/04 at 17:52
Regular
"It goes so quickly"
Posts: 4,083
Is it possible to have an image map submit the coordinates clicked to a PHP script?

I'm pretty sure web browsers let you do this, but not really sure how to make PHP aware that they exist.

What I'm after is a simple script that will tell me the coordinates of the image map that the user selected.
Sun 31/10/04 at 19:43
Regular
"It goes so quickly"
Posts: 4,083
Figured it out, for anybody who's interested.

xHTML:

mapismap="ismap" />


The ismap="ismap" attribute makes the browser append the x and y coordinates to the HREF URL as a query string, such as: map.php?125,467, with the x coordinate being first and the y coordinate being second. The PHP script can read this through its $_SERVER['QUERY_STRING'] superglobal

PHP:
$coords = explode(",",$_SERVER['QUERY_STRING']); # Split coordinates.
$x = trim($coords[0]); # Assign $x the x coordinate.
$y = trim($coords[1]); # Assign $y the y coordinate.
?>
Sun 31/10/04 at 18:13
Regular
"It goes so quickly"
Posts: 4,083
Yeah, the x and y coords related to the image, such as "user clicked: x - 172px, y - 65px".

I'm sure that it was built into HTML image maps, but was never sure how it worked, nor if its part of xHTML.

Its been a while since I've done anything major with JavaScript too. Do you mean have JS take note of the coords clicked and then append it to the URL link as a query string?
Sun 31/10/04 at 18:03
Regular
"Pouch Ape"
Posts: 14,499
You mean the x and y coords of the mouse when you click a link? I'm pretty sure JavaScript can do it, but can't remember how exactly.
Sun 31/10/04 at 17:52
Regular
"It goes so quickly"
Posts: 4,083
Is it possible to have an image map submit the coordinates clicked to a PHP script?

I'm pretty sure web browsers let you do this, but not really sure how to make PHP aware that they exist.

What I'm after is a simple script that will tell me the coordinates of the image map that the user selected.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Continue this excellent work...
Brilliant! As usual the careful and intuitive production that Freeola puts into everything it sets out to do, I am delighted.
Excellent support service!
I have always found the support staff to provide an excellent service on every occasion I've called.
Ben

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.