Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1944 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Javascript :

If...Else If help

Thread title: If...Else If help
     
    Thread tools Search this thread Display Modes  
Prev Previous Post   Next Post Next
08-31-2008, 09:08 AM
#1
Normo is offline Normo
Normo's Avatar
Status: Member
Join date: Aug 2008
Location: Hampshire, UK
Expertise:
Software:
 
Posts: 202
iTrader: 1 / 100%
 

Normo is on a distinguished road

  Old  If...Else If help

Ok so I have an image replacement code I'm working on, but I can't seem to get it working. Can anyone find the problem with this code:

Code:
function ShowImg() {
 if (document.getElementById("1")) {
  document.getElementById("background").src = "images/banner.png";
} else if (document.getElementById("2")) {
  document.getElementById("background").src = "images/text.png";
} else {
  document.getElementById("background").src = "images/bannerthin.png";
}};
Code:
<a href="#" id="1" onmouseover="ShowImg()" onmouseout="Backstep()">1</a>
<a href="#" id="2" onmouseover="ShowImg()" onmouseout="Backstep()">2</a>
What happens is it shows the first image (banner.png) but when you hover over the second link, instead of it showing text.png it shows banner again.
Any help is appreciated.

     


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed