Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 13th, 2005, 07:20 AM
Authorized User
Join Date: Feb 2005
Location: delhi, delhi, India.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Swapping Images

Dear Friends ,

 Hope to find all of u in best spirits .
 I am facing a problem in javascript. basically i have four images which are coming from the database. i actually want to replace those images by clicking on a button (or image itself). basically a product has four views . (ie product is being seen from the four angles). when user clicks a button , those images got swapped .ie other image comes into the active window. (The Basic requirement is the funda of swapping images )

  infact Visit this link plz & click on the image


 How can i make that .
 i'll be thankful

Cheers :
K K Singh.

Why to be GOOD when U have the ability to be GREAT
Cheers :
K K Singh.

Why to be GOOD when U have the ability to be GREAT
  #2 (permalink)  
Old April 13th, 2005, 10:00 AM
Friend of Wrox
Join Date: Jun 2003
Location: , , USA.
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Moharo

this is very simple...

1. have the "id" and/or "name" attribute for the big image (example "bigImage")
2. when those links below are clicked, read and change "src" attribute of an <img>
3. you are done....

consider following:

<script language="JavaScript">

var imgs = new Array('photo1.gif','photo2.gif');

function setImage(index)
  document.getElementById('bigImage').src = imgs[index];


<img src="x.gif" name="bigImage" id="bigImage">
<a href="" onClick="setImage(1)"; return false;">photo1</a>
<a href="" onClick="setImage(2)"; return false;">photo2</a>

hope that helped

www.campusgrind.com - college portal

Similar Threads
Thread Thread Starter Forum Replies Last Post
Load Images from and Save Images to a Database cyndie VB.NET 2 August 17th, 2008 06:42 AM
Images OldCoder ASP.NET 2.0 Professional 0 November 11th, 2007 09:17 PM
Session ID swapping from user to user... greenwar VS.NET 2002/2003 3 September 7th, 2007 08:44 AM
problem with swapping image into a div wilfordbrimley Javascript How-To 1 April 8th, 2006 04:52 PM
swapping characters in a string pritz VB How-To 1 August 22nd, 2005 12:19 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.