Jump to content

Recommended Posts

I have this code that simply changes an image when something is selected in a form. It finds this image name "pic4" and changes its file path "transparent1.gif" to green.gif, or orange.gif, depending on what was selected.

 

The image code at the start:

<IMG SRC="images/leaf_shapes/entire/transparent1.gif" name="pic4" width="250" height="350" border="0">

 

But I want it to only do so if "pic4" is still "transparent1.gif" as there's another button choice that it could be overriding. Any thoughts on how? I'm new to javascript.

 

function change1(picName,imgName)

{
   if (document.images)
    {
      imgOn=eval(imgName + ".src");
      document[picName].src= imgOn;
    }
}

An update:

I've gotten this far, but it still doesn't work at all.

 

 

function changecolor(picName,imgName)

{ 
     var leafcolor = document.getElementById('picName').src;
   if (leafcolor == "/images/leaf_shapes/entire/transparent1.gif")
    {
  document.getElementById('picName').src="/images/leaf_shapes/entire/leafbg_green.gif"
    } else {
	imgOn = eval(imgName + ".src");
      document[picName].src= imgOn; }
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.