/    Sign up×
Community /Pin to ProfileBookmark

My Site won’t work, Spot The Ball Style

I am creating a page here

[url]http://hbarsenal.co.uk/page2.html[/url]

as you can see I can’t get the images to appear. What you should see is an image and then a crosshair over the top. The person then selects a position on the grid by clicking. Do you know why my images aren’t showing.

My Code;

<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=”backg.jpg” width=”500″ height=”500″ id=”picture” onClick=”placeCrosshair(event)” />
<img src=”newcrosshair.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 created the images in Adobe Photoshop at 500 x 500 pixels and 21 x 21
I have placed the pictures in the image folder under puble_html

and the files paths are the same i.e. gif is gif not GIF.

Any ideas?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMaySep 03.2006 — Where did you place the html? If it's not in the same directory as the images you'll need to give either a relative or full path to them.
Copy linkTweet thisAlerts:
@CrazyMerlinSep 03.2006 — the reason you cannot see the crosshair is that you have it's display set to none.
Copy linkTweet thisAlerts:
@benrbrtsauthorSep 03.2006 — Cool, The Bear May have done that. So that works spot on.

http://hbarsenal.co.uk/page2.html

As you can see the picture is there and the crosshair but the crosshair lands well above where you click any ideas?

Also do you know how I'd get the PayPal button to work, i.e. you click and the XY value appears on paypal payment.
×

Success!

Help @benrbrts 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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