Jump to content

Image Scroller


sean04

Recommended Posts

Hey guys,

 

I have been looking for a specific image scroller but I can't seem to find one. I have attached a picture of the one that I would like. I'm assuming I would use javascript :P If someone has an idea of where I can find one that would be great. I realize that this is quite basic :P

 

Thanks,

Sean

 

[attachment deleted by admin]

Link to comment
Share on other sites

I think what you are after is more of a CSS/Style issue than a JavaScript issue. The JavaScript is very simple. Here's a working example:

<html>
<head>
<style>

#imgControl { width:350px; height:300px; }
#imgDisplay { width: 350px; height: 225px; text-align: center; border: 1px solid #000000; }
#imgList { width: 350px; height: 75px; overflow: auto; white-space: nowrap; border: 1px solid #000000; }
.thumb { height: 45px; width:45px; }
</style>

<script type="text/javascript">
function showImage(imageName)
{
    var path = 'images/'; //path to images folder
    var imgObj = document.getElementById('displayedImg');
    imgObj.src = path + imageName;
    return;
}

</script>
</head>
<body>

<div id="imgControl">

  <div id="imgDisplay">
    <img src="blank.jpg" id="displayedImg" />
  </div>

  <div id="imgList">
    <a href="#" onclick="showImage('image1.jpg');"><img src="images\thumbs\thumb1.jpg" class="thumb" /></a>
    <a href="#" onclick="showImage('image2.jpg');"><img src="images\thumbs\thumb2.jpg" class="thumb" /></a>
    <a href="#" onclick="showImage('image3.jpg');"><img src="images\thumbs\thumb3.jpg" class="thumb" /></a>
    <a href="#" onclick="showImage('image4.jpg');"><img src="images\thumbs\thumb4.jpg" class="thumb" /></a>
    <a href="#" onclick="showImage('image5.jpg');"><img src="images\thumbs\thumb5.jpg" class="thumb" /></a>
    <a href="#" onclick="showImage('image6.jpg');"><img src="images\thumbs\thumb6.jpg" class="thumb" /></a>
    <a href="#" onclick="showImage('image7.jpg');"><img src="images\thumbs\thumb7.jpg" class="thumb" /></a>
    <a href="#" onclick="showImage('image8.jpg');"><img src="images\thumbs\thumb8.jpg" class="thumb" /></a>
    <a href="#" onclick="showImage('image9.jpg');"><img src="images\thumbs\thumb9.jpg" class="thumb" /></a>
  </div>

</div>

</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.