/    Sign up×
Community /Pin to ProfileBookmark

javascript spot the ball game

? I’m trying to create a project, i have set up my mambo CMS with content, then what i’m trying to do is create a competition like this one [url]http://www.bestofthebest.co.uk/botb2…acds?instancei[/url]
d=1239860&ticket_id=549066
its a spot the ball competition which when you make your choice it collects the co-ordinates and puts them in x & y boxes. Would the following work?(i’m not a coder, i found the below on the internet):

Assume you have picture and crosshair GIF (21×21)<html>
<head>
<title>Test</title>
<style type=”text/css”>
img#crosshair {
position: absolute;
display:none;
}
</style>

<script>
function placeCrosshair(e) {
var ch = document.getElementById(‘crosshair’);
var pic = document.getElementById(‘picture’);
ch.style.display = ‘block’;
ch.style.left = e.x – 11;
ch.style.top = e.y – 11;
document.coords.x.value = e.x – pic.offsetLeft;
document.coords.y.value = e.y – pic.offsetTop;
}
</script>
</head>

<body>
<img src=”picture.jpg” width=”500″ height=”500″ id=”picture” onClick=”placeCrosshair(event)” />
<img src=”crosshair.gif” width=”21″ height=”21″ id=”crosshair” />
<form name=”coords”>
X: <input type=”text” size=”5″ readonly=”true” name=”x” /><br />
Y: <input type=”text” size=”5″ readonly=”true” name=”y” />
</form>
</body>
</html>

I need to be able to keep the picture files secure (maybe in a protected folder, each competition would then need to have a unique id for checkout process and calling pictures from the protected file)

thanks
David stanton

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @davestanton 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.16,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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