Jump to content

Interacting with images


Arekanderu

Recommended Posts

Hello All!

I will describe a small problem of mine and i am hoping that somebody can give me an elegant solution.

[What I want to do]

I am developing a PHP application which it will output at the user a small image with various objects on fixed positions on the image. The user will then be able to drag the mouse on a object, click on it and output information about it. e.g object type, sizeetc. The info for each object are stored in a MySQL db.

[The question]

As you understand i want to dynamically load the information for each object each time a user "clicks" on a object . What i am having trouble with is HOW am i going to put clickable stuff inside a static image ( the map ) and through PHP will be able to output some useful info to the user. In addition, the image should also be drawn dynamically since i want to show at the user which object is at the moment ocupied by being red ( this info will also be at the DB ). I know that you can do this through GDI but how am i going to do it if i want to combine it with the other thing.

If my question isn't that clear or if you think i can help more understanding it please let me know.

I have found couple solutions which i do not like so it would really save me some time if anyone has any suggestions. I do not mind using other stuff inside my PHP code ( e.g jscript ) in order to get where i want.

Somebody did suggest me map tag of HTML but i want something more dynamic.

Cheers and thanks for any replies!
Link to comment
Share on other sites

If you use a form image

[code]<INPUT type='image' src='myimage.php' name='myimage'>[/code]

Then it will behave like a button, submitting the form when clicked.

To process

[code]$xpos = $POST['myimage_x'];

$ypos = $POST['myimage_y'];[/code]

You now have the coords of the mouseclick within the image. If you know the positions of the objects in your image then you can determine which object was clicked.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.