Jump to content


dw cs3 troubles


2 replies to this topic

#1 laste

    Young Padawan

  • Members
  • Pip
  • 13 posts
  • Gender:Male
  • Location:Sofia/Plovdiv, Bulgaria

Posted 02 August 2008 - 02:30 AM

Greetings

I'm having a hard time using the swap image function in dw, my goal is when hovering an image with your cursor to swap both the image your hovering and another one thats right next to it and while that works dandy its the Swap Image Restore function I'm having trouble with, it restores only one of the images, it would appear I cannot set them in this order

swap image
swap image restore
swap image
swap image restore

I can't do it in the code either because it says I can't have two onMouseOver's in one line =s

I'm a complete coding nub, so I have no idea how to do this any other way, if its achievable via any other means please let me know.

thanks,
-laste

#2 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 03 August 2008 - 03:35 AM

Could you show us any code you have please?

this is the easist way I can think of doing it:

<img src="imageOneIn.png" alt="Image One" id="imgOne" onMouseOver="swapImage()" onMouseOut="swapImage()" />
<img src="imageTwoIn.png" alt="Image Two" id="imgTwo" onMouseOver="swapImage()" onMouseOut="swapImage()" />

<script type="text/javascript">

function swapImage() {

	var imageOne = document.getElementById( 'imgOne' );
	var imageTwo = document.getElementById( 'imgTwo' );

	if( imageOne.src == 'imageOneIn.png' ) {

		imageOne.src = 'imageOneOut.png';
		imageOne.src = 'imageTwoOut.png';

	} else {

		imageOne.src = 'imageOneIn.png';
		imageOne.src = 'imageTwoIn.png';		

	}

}

</script>

Haven't dont any testing but it should be fine, just make sure to change the urls of the images in the JS otherwise it won't work!

Edited by Mr. Matt, 03 August 2008 - 03:36 AM.


#3 laste

    Young Padawan

  • Members
  • Pip
  • 13 posts
  • Gender:Male
  • Location:Sofia/Plovdiv, Bulgaria

Posted 21 August 2008 - 08:05 PM

sorry for the horribly late reply, I just dropped by to say a million thanks.

script worked like a charm and it set me on the right track.

cheers!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users