Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript image and href swap on image gallery
    primarykey
    data
    text
    <p>I have an image gallery on my site that has one large display image with caption and 3 smaller thumbnail images below. Right now, I have a javascript that enables the display image and caption to be swapped out when you click on the different thumbnails. My end goal, and what I am having difficulty with is to have each of the large display images link to a different video.</p> <p>My faulty javascript which works for display image and caption swapping but not link swapping is this:</p> <pre><code>function showPic (whichpic) { if (document.getElementById) { document.getElementById('placeholder').src = whichpic.href; document.getElementById('link').href = whichpic.video; if (whichpic.title) { document.getElementById('desc').childNodes[0].nodeValue = whichpic.title; } else { document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue; } return false; } else { return true; } } </code></pre> <p>The HTML is as follows:</p> <pre><code>&lt;div id="itemart"&gt; &lt;script src="js/showPic.js" type="text/javascript" language="javascript"&gt;&lt;/script&gt; &lt;a id="link" href="http://www.youtube.com/watch?v=SgARL8aHl8Q" title="Video Title" class="lightbox" data-height="480"&gt;&lt;img id="placeholder" src="img/Coke_01_AnimationStoryboard.png" alt="Coca-Cola Plastic Recycling Animation." /&gt;&lt;/a&gt; &lt;p id="desc"&gt;Display image 01 caption.&lt;/p&gt; &lt;ul class="thumbnails"&gt; &lt;li&gt;&lt;a onclick="return showPic(this)" href="img/Coke_01_AnimationStoryboard.png" title="Coca-Cola plastic recycling animation storyboard." video="http://www.youtube.com/watch?v=SgARL8aHl8Q"&gt;&lt;img name="itemarttthumbnail1" width=50 height=50 src="img/thumbs/Coke_01_thumb01.png" alt="Cola-Cola Plastic Recycling Animation" style="background-color: #00FF66" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a onclick="return showPic(this)" href="img/Coke_02_AnimationStoryboard.png" title="Coca-Cola aluminum recycling animation storyboard." video="http://www.youtube.com/watch?v=Wq2GbbMJ20Q"&gt;&lt;img name="itemarttthumbnail2" width=50 height=50 src="img/thumbs/Coke_02_thumb02.png" alt="Coca-Cola Aluminum Recycling Animation" style="background-color: #00FF66" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a onclick="return showPic(this)" href="img/Coke_03_AnimationStoryboard.png" title="Coca-Cola glass recycling animation storyboard." video="http://www.youtube.com/watch?v=qU5TOA3kWPs"&gt;&lt;img name="itemarttthumbnail3" width=50 height=50 src="img/thumbs/Coke_03_thumb03.png" alt="Coca-Cola Glass Recycling Animation" style="background-color: #00FF66" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I am not very adept with Javascript so I may be missing something very obvious. Any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload