Welcome to WebmasterWorld Guest from 54.160.221.82

Forum Moderators: open

Message Too Old, No Replies

simple javascript question

make select change when image is clicked

     
4:16 pm on Aug 14, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:May 14, 2003
posts:93
votes: 0


I have a bunch of color options. When someone clicks on it, the image changes via javascript. I also want the select menu to change to reflect the color clicked. Also if someone changes the color in the select menu, I want the picture to change. This is what i'm using for the color change:


thumb =new Image();
thumb2=new Image();

thumb.src ="images/white2.jpg"
thumb2.src="images/black2.jpg"

function thumbtobig(thumbs)
{
if(thumbs==1){document.images['large'].src=thumb.src;}
if(thumbs==2){document.images['large'].src=thumb2.src;}
}

<a href="javascript:thumbtobig(1)"><img src="images/white.gif"></a>

<a href="javascript:thumbtobig(2)"><img src="images/black.gif"></a>

A point in the right direction would help me a lot. I dont work with JS that often so i'm a little rusty. Thanks.

6:09 pm on Aug 14, 2003 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15755
votes: 0


you could add an onChange event to the select box and maybe a parameter to your function to differentiate between a click and the select.

I haven't tried to auto switch the selectedIndex in a drop down but I would imagine it should work.