/    Sign up×
Community /Pin to ProfileBookmark

Clickable mouse position on image highlight.

Hi,

How to do the clickable mouse position on image highlight? My situation is i need the user click on the image/picture that display in the browser, then retrieve the value click position and finally the value are save to database. And the sequence of the click position of the image also be store to database. One more function is to display the click sequence before store to database.

Thanks.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 25.2009 — Create an input form element of type "image" and it will function as a submit button that also sends the x and y coordinates that were clicked.
Copy linkTweet thisAlerts:
@wterauthorMar 25.2009 — i already see the link you provide. But i still not understand the meaning you try to said. Perhaps you can provide example for me?
Copy linkTweet thisAlerts:
@NogDogMar 25.2009 — [code=php]
<html>
<head>
<title>Form</title>
</head>
<body>
<form action="" method="post">
<fieldset>
<legend>Click anywhere on the photo</legend>
<input name="submit" type="image" src="http://www.charles-reace.com/Photos/noggin1.jpg">
</fieldset>
</form>
<?php
if(!empty($_POST['submit_x']))
{
printf("You clicked at x=&#37;d and y=%d on the image.", $_POST['submit_x'], $_POST['submit_y']);
}
?>
</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@wterauthorMar 25.2009 — Thanks for reply.Do you mind i modified your code little bit? Because i wan user click five time at different position and for each click position will display the coordinates. But my modified code do not work. What is the meaning of &#37;d?

[code=php]
<html>
<head>
<title>Form</title>
</head>

<body>
<form action="" method="post">
<fieldset><legend>Click anywhere on the photo</legend>
<input name="submit" type="image" src="http://www.charles-reace.com/Photos/noggin1.jpg"></fieldset>
</form>
<?php
for($i=1;$i<6;$i++){
$x=$_POST['submit_x'][$i];
$y=$_POST['submit_y'][$i];

if(!empty($x)){
printf("You clicked at x=%d and y=%d on the image.", $x,$y );
printf("</br>");
}
}
?>

</body>
</html>
[/code]


And if the coordinate X and Y are store to database, when we load the same image again; how we determine the user click at right position X and Y because user might do not know the exact point X and Y click before and impossible for the user click exactly on it?

Thanks.
×

Success!

Help @wter spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...