Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 1st, 2006, 05:54 AM
Authorized User
 
Join Date: Aug 2006
Location: , , .
Posts: 20
Thanks: 4
Thanked 0 Times in 0 Posts
Default swap image onclick

Hi there!
Currently i am facing problem with swaping an image using javascript.
What i'm trying to do is when i click on the hyperlink the image is changed to another image.
<a href="#" onclick="ChangePic()"><image name="img" src="somepic.jpg"></a>
I have done till here...when i click the link the new image is loaded
but when i again click the pic the other image ... how to keep track which image to load???
i want to toggle between two images
i'm a newbie so plz...

HELP!!!!!!!!!
Reply With Quote
  #2 (permalink)  
Old November 8th, 2006, 01:35 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii The Beginner!!
Hope this will help you
<script>
function ChangePic(currentPicToShow,val)
{
hrIds=document.getElementsByName("hrid")
imgObj=document.getElementsByName("imgname")
str=imgObj[val].src
hrIds[val].onclick=function(){ChangePic(str,val)};
imgObj[val].src=currentPicToShow
}
</script>

<a name="hrid" href="#" onclick="ChangePic('callsheet.jpg',0)"><image name="imgname" src="exit.jpg" ></a>
<a name="hrid" href="#" onclick="ChangePic('callsheet.jpg',1)"><image name="imgname" src="exit.jpg" ></a>
<a name="hrid" href="#" onclick="ChangePic('exit.jpg',2)"><image name="imgname" src="callsheet.jpg"></a>


Cheers :)

vinod
Reply With Quote
The Following User Says Thank You to vinod_yadav1919 For This Useful Post:
The Beginner (December 18th, 2008)
  #3 (permalink)  
Old November 8th, 2006, 08:42 AM
Authorized User
 
Join Date: Aug 2006
Location: , , .
Posts: 20
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Thanx a lot...
i hope this helps me out...


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to swap the table column value shahidmca SQL Language 2 July 31st, 2007 06:43 PM
Image button onclick msbsam ASP.NET 2.0 Basics 0 December 30th, 2006 04:47 AM
Swap Images Mike707 Dreamweaver (all versions) 3 December 18th, 2006 01:05 PM
Problem to Swap two number in C# furqanms C# 1 June 5th, 2006 05:12 PM
How to Swap two integers without temp variable ramk_1978 C# 2 February 28th, 2006 08:03 PM



All times are GMT -4. The time now is 05:32 AM.


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