I know how to draw rectangles in PHP (with GD), but how do we make them interactive ? I mean, is there a way to be notified when and where the user clicks ?
Eventually, I would like to enable the user to select a rectangle among a set by clicking on it, and clicking anywhere else to move it.
Thanks aforehand.
Regards,
Mister Mystère.
You can do this with image maps. This applies however you create the image. The basic syntax (from Wikipedia) is:
You can have any number of
areaelements. You can either use a regular href URL as shown above, or use JavaScript events. All the typical mouse events are supported (onclick, onmouseover, onmouseout, onmousedown, onmouseup, etc.)If you only have simple rectangles, an alternative without maps is to just position several images contiguously with no margin or padding.