Image Rollover and OnClick

Hi,

I have this onClick and mouseover script for a set of images with a "on" and "off" state.

The problem I have is that although the onClick works and it changes the image's "off" state to "on", I always need to right click and click "Show Picture" to make the image visible.

Why would this happen?

I am using "eval" to dynamically find the image and change the src.

Thanks for any help in advance.
LVL 6
rajesh75Asked:
Who is Participating?
 
TimYatesCommented:
isn't this easier?

    function BOGo( tImg )
    {
         tImg.src = './Images/admod_' + tImg.id + '_on.gif' ;
    }

    <img src="Images/admod_vac_off.gif" border="0" id="vac" border="0" onclick="BOGo( this )">

Tim
0
 
TimYatesCommented:
Can you post your code?
0
 
rajesh75Author Commented:
Javascript:


function BOGo(id) {

      switch (id)
                  {      case "car" :
                              flg = "car";
                              break;
                        case "hotels" :
                              flg = "hotels";
                              break;
                        case "vac" :
                              flg = "vac";
                              break;
                        case "lastmin" :
                              flg = "lastmin";
                              break;
                                          }
                  
      eval("document." + flg + ".src = \"./Images/admod_" + flg + "_on.gif\"");
}

Calling function:

<A onclick="BOGo('vac');" href="javascript:void(0);"><Img src="./Images/admod_vac_off.gif" border="0" name="vac" border=0>

Thanks.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
rajesh75Author Commented:
Thanks Tim. This is a cross browser script right? Would this work on some of the older versions of Netscape and IE?

Thanks again.
0
 
TimYatesCommented:
as far as I know...  I've not been doing javascript long though...  so I may be wrong :-/
0
 
rajesh75Author Commented:
I'd like to test this script on a few older browsers and if everything goes well, you got the points !

Thanks.
0
 
TimYatesCommented:
Good luck..it shoud work (as far as I know), as its not really doing anything fancy :-)

*crosses fingers*

Tim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.