473,405 Members | 2,282 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,405 software developers and data experts.

html image swapping problem

I spent hours trying to find an example of
onMouseOver and onMouseOut and OnClick. I did find somethings about
onMouseOver and onMouseOut but not the onClick.

can you please help me with an example

Thanks
Nov 13 '07 #1
11 1534
drhowarddrfine
7,435 Expert 4TB
Did you use Google? There should be millions of examples. In any case, this is not a html question so I'll transfer you to the javascript board.
Nov 13 '07 #2
gits
5,390 Expert Mod 4TB
hi ...

please post some code you have done and tell where you have particular problems with it ...

kind regards
Nov 13 '07 #3
Death Slaught
1,137 1GB
"Hours" your exagerating, any search engine would have and will give you an example instantly, if you were look through a book I advise you burn it, or sell it on ebay, it will be no use to you if it doesn't even have basic material in it.

Here's a tutorial on JavaScript I highly advise you read it all and do so carefully.

If you had read the Posting Guidelines , you would have seen that we are not aloud to simply give you the answer, however, we are aloud to point you in the right direction. After reading the tutorial I gave you, if you are still confused about something feel free to post again, but try it on your own first, and post your code, then we will be glad to help you further.


Hope it helps, Thanks, Death
Nov 13 '07 #4
acoder
16,027 Expert Mod 8TB
I spent hours trying to find an example of
onMouseOver and onMouseOut and OnClick. I did find somethings about
onMouseOver and onMouseOut but not the onClick.

can you please help me with an example
See the link provided by Death Slaught. If you've got an example of onmouseout and onmouseover, onclick is pretty much the same.
Nov 14 '07 #5
Here is what i have:

[HTML]<script type="text/javascript">
function swap()
{
document.getElementById("b1").src ="images/buttons/Buy2.gif"

}
</script>


<a href="Buy.aspx" target="_blank">
<img border="0" alt=" " src="images/buttons/Buy.gif" name="b1" onclick="swap()" /></a>
[/HTML]


The code works fine but there is a problem: when i click on the button "Buy" it will open a new window with the image Buy2.gif. I want the image to change to Buy2.gif and stay at the same window. So i changed the target = "_self" but the problem the page will always go back the imae Buy.aspx which is the default one

your input will be appreciated!
Thanks
Nov 24 '07 #6
Markus
6,050 Expert 4TB
You have:
Expand|Select|Wrap|Line Numbers
  1. getElementById('b1')
  2.  
Expand|Select|Wrap|Line Numbers
  1. <img NAME="b1" src="sda.jpg" />
  2.  
See how you have NAME specified as 'b1' and not ID
change it to this
Expand|Select|Wrap|Line Numbers
  1. <img id="b1" border="0" alt=" " src="images/buttons/Buy.gif" name="b1" onclick="swap()" />
  2.  
Oh wait, i misread your problem!

Sorry..

For the problem you have, all i can think of is with the onlick() function, set a cookie in that? And then read it to see which image should be displayed?

For the <a href="someplace.php" target="_self">
just leave the target="_self" out. It isn't neccesary.
Nov 24 '07 #7
Thank you for your input. I did what you suggested I took the target="_self" out and still not working. what happened is the image changed to Buy2.gif for one second then it went back to the Buy.gif image. it only works if i do target="_blank" but it will open it in a new window which is not what i want to do.

I think the problem is with page post back. this script is in a master page that is called by Buy.aspx page so when i click on the button it will change the image to buy2.gif, but when it loads again the image go back the buy.gif which is the default one?
any thoughts!
Nov 24 '07 #8
acoder
16,027 Expert Mod 8TB
You will need to set a cookie to 'remember' which image is to be displayed.

See this article or this tutorial.
Nov 26 '07 #9
Death Slaught
1,137 1GB
You shouldn't need cookies if the image that was specified isn't supposed to go to that specific user. Useing variables is alot easier.

- Death

PS - I've got a code at my house that I did after I saw this thread, if you haven't figured it out by then I'll give it to you.

PSS- WOOT! 300 POST!
Nov 26 '07 #10
acoder
16,027 Expert Mod 8TB
You shouldn't need cookies if the image that was specified isn't supposed to go to that specific user. Useing variables is alot easier.
If he wants to remember that the image has changed even after the page has reloaded, he will need cookies.
PSS- WOOT! 300 POST!
Congratulations!
Nov 26 '07 #11
Death Slaught
1,137 1GB
If he wants to remember that the image has changed even after the page has reloaded, he will need cookies.

Congratulations!
Yeah there's a few options for him, and thanks, Death
Nov 26 '07 #12

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

Similar topics

5
by: Richard | last post by:
I'm beginning to undertake php for the fun of it. Working on a problem I hope can be solved in php. Basically what I have is this: <body> <img name="main" src="image1.jpg"> <a href="#"...
2
by: uNConVeNtiOnAL | last post by:
Hi - I have a page that has a button that makes a prompt appear for the user to type input. When they have typed in input, I want the button to change color when the prompt closes. I am...
18
by: Arthur Connor | last post by:
Is there a way of extracting the Javascript code from the "normal" HTML code (e.g. similar to CSS code which can be put into a separate file) ? If you offer a solution: can I determine in your...
2
by: robert | last post by:
I've made a gallery site for an artist and it works well -- the gallery page has a central large image which is swapped when thumbnail images are clicked. I'm using Dreamweaver's "SwapImage"...
1
by: Richard | last post by:
Server not posting timely today. In understanding how this works, would it not be possible then to replace an item with another? For instance, I have the first paragraph of "Lorem Ipsum"...
4
by: MB | last post by:
Hello everyone! These lines were inspired by the "DIV without line breaks" posted by Johnny Two Dogs on June 22. I know it is an old issue, but I want to share a few remarks that could be of...
6
by: cjl | last post by:
I have a website which allows people to view interesting radiology cases. It is for teaching radiology residents. It is designed to run in fullscreen or 'kiosk' mode, at 1024 x 768 resolution...
7
by: cjl | last post by:
OK: I am really scratching my head over a preload / image swapping problem, so I started conducting experiments: http://www.saintrays.net/experiment1.html...
5
by: Guadala Harry | last post by:
In an aspx page I have declared an Image control: <asp:Image id="myImage" runat="server"></asp:Image> In the code-behind I populate it's ImageURL property, like this: myImage.ImageUrl =...
3
by: seamlyne | last post by:
The first method I ever used for multiple state buttons was to create a graphic for each button for each state: AboutUs_on, AbooutUs_over, AboutUs_out, etc. That works great when there are just a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.