473,756 Members | 4,165 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

html image swapping problem

25 New Member
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 1575
drhowarddrfine
7,435 Recognized Expert Expert
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 Recognized Expert Moderator Expert
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 Top Contributor
"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 Recognized Expert Moderator MVP
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
goal2007
25 New Member
Here is what i have:

[HTML]<script type="text/javascript">
function swap()
{
document.getEle mentById("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 Recognized Expert Expert
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
goal2007
25 New Member
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 Recognized Expert Moderator MVP
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 Top Contributor
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

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

Similar topics

5
2954
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="#" onMouseOver="document.main.src='image2.jpg'"
2
1584
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 trying to do image swapping This snippet will prevent 'null' from appearing initially and successfully records user changes (typing in a comment)
18
4390
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 solution where and which part of the code should be placed/inserted in the main HTML code? Sometimes a Javascript functionality is split up to several parts and/or it makes a big difference where the Javascript code should run/be called (e.g. -...
2
2534
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" behavior. The problem is that this fails under certain versions of IE and possibly NN on PCs and Macs -- I haven't gotten my client to send me details of what version he's using (sorry) or any of my 'beta testers' -- but I'm really getting frustrated....
1
1101
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" shown in a division. At the bottom is a ling showing "next". Click on the link, the next paragraph replaces te previous.
4
4119
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 interest for many members of this group. A brief summary is given below. However, you may want to take a look back at the original posting before continuing.
6
2267
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 only. http://www.casespace.net I designed it with firefox (plus the autohide extension) in mind, but also want to support IE. Online and offline it works great in Firefox. Offline it also works
7
9108
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 http://www.saintrays.net/experiment2.html http://www.saintrays.net/experiment3.html View the source of each page to see the relevant javascript. All three
5
2245
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 = "some.gif"; Then, in client-side JavaScript, the user can cause the image to be replaced, like this: document.all("myImage").src = "other.gif";
3
5669
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 few buttons. I'm creating interfaces now with many more buttons than "just a few". I solved the maintenance problem by having generic button images, one for each state, and having them be background images for text containers, DIVs in this...
0
9487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9297
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10069
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9904
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9884
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9735
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.