icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.
Old July 10th, 2008, 8:58 AM   #1 (permalink)
JMF
Registered User
Seasoned Poster
 
JMF's Avatar
 
Joined in Jun 2004
Lives in Tennessee, USA
Hosted on Pass56
38 posts
Gave thanks: 1
Thanked 1 Time in 1 Post
Unhappy Stupid Newbie Javascript Question

For as long as there's been Javascript, we haven't gotten along; I have no explanation for this... Anyway, I'm trying to write a tiny, tiny piece of simple code that, as far as I can tell, should work but doesn't, and I can't understand why not.

Here's the whole thing:

Code:
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript">
    function showPic(source) {
        alert(source);
        var viewer = getElementByID("viewer");
        viewer.setAttribute("src",source);
    }
</script>
</head>

<body>

<img src="exerIII-resources/village-map.jpg" width="600" height="402" usemap="#village-map" border="0">
<map name="village-map">
    <area shape="circle" coords="364,179,24" href="#" title="Look at this!" onmouseover="showPic('exerIII-resources/green-dome.jpg');">
</map>

<img id="viewer" src="exerIII-resources/empty.jpg" width="300" height="300" />

</body>
</html>
When I open the page, and mouse over the area on the image map, the alert in the showPic function fires off, but nothing else.

I'm simply trying to display an image in a box when parts of a map are run over -- should be pretty simple, right?

Can somebody point out what I'm doing wrong??

Thanks,
J.
JMF is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 10th, 2008, 10:51 AM   #2 (permalink)
Surpass Fan
Excelling Contributor
 
cowboy's Avatar
 
Joined in Nov 2005
Lives in Colorado
Hosted on DEDI
937 posts
Gave thanks: 2
Thanked 95 times
var viewer = document.getElementById("viewer");

case sensitive; ID should be Id
document; tell the browser where to find the element

Code; include your <!DOCTYPE so browsers don't have to guess
__________________
Where would you be if you were at the highest court in the land (US)?
cowboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 10th, 2008, 11:12 AM   #3 (permalink)
JMF
Registered User
Seasoned Poster
 
JMF's Avatar
 
Joined in Jun 2004
Lives in Tennessee, USA
Hosted on Pass56
38 posts
Gave thanks: 1
Thanked 1 Time in 1 Post
Shucks. I knew it was something simple. Thanks a LOT!

(DOCTYPE on the way -- just scratching around, for now! )
JMF is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 10th, 2008, 12:53 PM   #4 (permalink)
Surpass Fan
Excelling Contributor
 
cowboy's Avatar
 
Joined in Nov 2005
Lives in Colorado
Hosted on DEDI
937 posts
Gave thanks: 2
Thanked 95 times
Quote:
Originally Posted by JMF View Post
Shucks. I knew it was something simple. Thanks a LOT!

(DOCTYPE on the way -- just scratching around, for now! )
DOCTYPE is always the first thing, especialy before script scratching.
__________________
Where would you be if you were at the highest court in the land (US)?
cowboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On