473,394 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

replacing a image in html

Hi all,

i have a image pic1 in my page and i need to replace pic1 by another image pic2 in the same position after clicking the button. what is the code to do it in html and javascript.

Is there any possibilty to replace a image?
Oct 11 '07 #1
4 3970
Death Slaught
1,137 1GB
Hi all,

i have a image pic1 in my page and i need to replace pic1 by another image pic2 in the same position after clicking the button. what is the code to do it in html and javascript.

Is there any possibilty to replace a image?
Try this:

[HTML]<html>
<head>
<script type="text/javascript">
function moveover()
{
document.getElementById('image').src="Image1"
}
function moveback()
{
document.getElementById('image').src="Image2"
}
</script>
</head>

<body>

<img id="image" src="Image2"
onmouseover="moveover()"
onmouseout="moveback()" width="100" height="180" />

</body>
</html>[/HTML]


Hope it helps, Death
Oct 11 '07 #2
Try this:

[HTML]<html>
<head>
<script type="text/javascript">
function moveover()
{
document.getElementById('image').src="Image1"
}
function moveback()
{
document.getElementById('image').src="Image2"
}
</script>
</head>

<body>

<img id="image" src="Image2"
onmouseover="moveover()"
onmouseout="moveback()" width="100" height="180" />

</body>
</html>[/HTML]


Hope it helps, Death
Thank you for your reply but the thing is "Once the button is pressed the link is to another page and after returning from that page the image1 should be changed into another image say image2 in the same position."
Oct 12 '07 #3
Try this:

[HTML]<html>
<head>
<script type="text/javascript">
function moveover()
{
document.getElementById('image').src="Image1"
}
function moveback()
{
document.getElementById('image').src="Image2"
}
</script>
</head>

<body>

<img id="image" src="Image2"
onmouseover="moveover()"
onmouseout="moveback()" width="100" height="180" />

</body>
</html>[/HTML]


Hope it helps, Death
Thank you for your reply but the thing is "Once the button is pressed the link is to another page and after returning from that page the image1 should be changed into another image say image2 in the same position." Could be please help me in this doubt with coding?
Oct 12 '07 #4
dmjpro
2,476 2GB
Thank you for your reply but the thing is "Once the button is pressed the link is to another page and after returning from that page the image1 should be changed into another image say image2 in the same position." Could be please help me in this doubt with coding?
So you want that page to be popped up in a new window?
And what do you mean by "After returning that page"?

Debasis Jana.
Oct 12 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Sorby | last post by:
Hi I've been coding in PHP for a little while now and was starting to feel pretty confident but then realise I need to understand regular expressions to solve a particular problem I've got ......
2
by: Moon | last post by:
Seems I still haven't got the hang of all those window generating code in Javascript. I've got a page with about 15 photo thumbnails. When you click on a thumbnail a new window pops up which shows...
6
by: Peter Foti | last post by:
I have seen lots of examples where some HTML text is replaced with a background image using CSS. For example, replacing the text of an <h1> with a graphical logo, like so: CSS: h1 span {...
7
by: Rob Meade | last post by:
Hi all, Been a long time since I've been here... /me waves to all.. Ok - my conundrum.. I have a form where a user can enter text and BB codes...for example:
4
by: Charles Crume | last post by:
Hello all; I have a web page that displays a blank gif for about 2 seconds, then displays an animated gif image, then, after the animation plays, I want to display a link so the user can click...
1
by: Andrew Poulos | last post by:
Say I have a page, which has been created by a third party, and the page may contain some pre-specified text. How can I find and replace that text dynamically? For example, if the page I have...
0
by: Blue Apricot | last post by:
I think this is straighforward enough so I don't need sample code, but I will make an example if someone doesn't understand. BACKGROUND: We have built a "skinnable" interface, which uses...
1
by: godrifle | last post by:
I hope this is the best way to explain what I'm trying to do, using PHP5. Given the following HTML sample... <html><head><title>The Page</title></head> <body> <h2>A Title</h2> <img...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.