I am new to this forum, forgive me if my post is incorrect. I have a site that i am have 3 images that switch places with eachother. one image is large and then there are two thumbnails. when you click the thumbnails the images rotate around. i am using the switch function and just setting IMG1.src different for each case. I want to make a function that will also play a sound byte when you click on the large image. i need the sound byte to change with the images. Here is the code that i am using. intImage = 2; function swapImage() { switch (intImage) { case 1: IMG1.src = "images/picture1-lg-over.png" IMG2.src = "images/picture2-sm-top.png" IMG3.src = "images/picture3-sm-btm.png" intImage = 2; return(false); case 2: IMG1.src = "images/picture2-lg-over.png" IMG2.src = "images/picture1-sm-top.png" IMG3.src = "images/picture3-sm-btm.png" intImage = 3; return(false); case 3: IMG1.src = "images/picture3-lg-over.png" IMG2.src = "images/picture2-sm-top.png" IMG3.src = "images/picture1-sm-btm.png" intImage = 1; return(false); } } Code (markup): i have tried many things that involved each case to contain a different IMG1.onClick=""; value but it doesnt seem to change when the case changes. I have also tried making another switch/case that would change the value of the onClick event.. nothing. any sugestions?
The code that i posted works fine. Check Here: tpsite.touchpointtechclients.net The problem i am having is getting the switch to also change the value of the onClick event. I am embedding 3 different sounds files in the code and i want to call on them based on which image is is in the "large" position...
Can you tell me why i am unable touse this same switch/case function to change the value of an onmouseover event? i would have coded it like this: Code: function swapImage(img) { var id = getIdFromImageSrc(img); var img1 = document.getElementById('IMG1'); var img2 = document.getElementById('IMG2'); var img3 = document.getElementById('IMG3'); switch(id) { case 1: IMG1.src = "images/picture1-lg.png" IMG2.src = "images/picture2-sm-top.png" IMG3.src = "images/picture3-sm-btm.png" IMG1.onmouseover = "MM_swapImage('Image1','','images/body-bg.png',1)" break; case 2: // .....if you can set the case to change the src value why cant you change any other value in the coding tags? Code (markup): Help is appreciated.. i am extremely new to coding javascript without the help of dreamweaver... i know.. boooooo. Thank you in advance!