[SOLVED] First Attempt at Basic Image Gallery Not Working...

This is a discussion on "[SOLVED] First Attempt at Basic Image Gallery Not Working..." within the JavaScript Forum section. This forum, and the thread "[SOLVED] First Attempt at Basic Image Gallery Not Working... are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 30th, 2007, 08:08
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
[SOLVED] First Attempt at Basic Image Gallery Not Working...

Hey all,

Started the road to using Javascript, and have made an image gallery. However, it is not working as it should. The 'return false' does not work.
HTML:
Code: Select all
<h3>Image Selector</h3>
<ul>
<li><a href="images\Bluehills.jpg" title="Blue Hills" onClick="showPic(this); return false;">Blue Hills</a></li>
<li><a href="images\sunset.jpg" title="Sunset" onClick="showPic(this); return false">Sunset</a></li>
<li><a href="images\lilies.jpg" title="Water Lilies" onClick="showPic(this); return false;">Water Lilies</a></li>
<li><a href="images\winter.jpg" title="Winter" onClick="showPic(this); return false;">Winter</a></li>

</ul>
<img id="placeholder" alt="My Image Gallery" src="images/placeholder4x3.jpg" width="400" height="300">
<p id="description">Choose an Image</p>
javascript:
Code: Select all
function showPic(whichpic) {
var source = whichpic.getAttribute("href");
var placeholder = document.getElementById("placeholder");
placeholder.setAttribute("src",source);
var text = whichpic.getAttribute("title");
var description = document.getElementById("description");
description.firstchild.nodeValue = text;
}
What is happening is that when you click the link it is just opening that picture in a new page, not where the placeholder is. If I take away the last 3 lines of javascript, it works. I'm following this from 'DOM Scripting' by Jeremy Keith.

I'm linking to the javascript external file with:
Code: Select all
<script type="text/javascript" src="java.js"></script>
Any ideas - I bet it's me with a stupid mistake

Many Thanks

Jack
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)

  #2 (permalink)  
Old Sep 30th, 2007, 08:14
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: First Attempt at Basic Image Gallery Not Working...

LOL!

Sorry people but it was my stupid mistake -I put 'firstchild' instead of firstChild.

It works now!

Shows how one error makes it all go wrong.

I guess this can be closed now.

Cheers
Jack
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Gallery Help McG Web Page Design 1 Apr 18th, 2008 01:29
[SOLVED] CSS image gallery Graisbeck Web Page Design 6 Dec 18th, 2007 08:07
[SOLVED] first attempt at writting php form from scratch narthex PHP Forum 10 Nov 6th, 2007 20:20
Image gallery not displaying enlarged image AdRock PHP Forum 15 Sep 1st, 2006 11:31
need an image gallery spellbyte Web Page Design 4 Mar 7th, 2006 13:45


All times are GMT. The time now is 00:01.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43