Jump to content


Javascript txt and image swap


3 replies to this topic

#1 aega

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 03 December 2008 - 11:07 AM

Hello, i need javascript for html page, it should work like that - there are thumbnails, and if i mouseover them, changes the image and text. can anyone help me?

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 03 December 2008 - 06:32 PM

You mean like what is discussed in the following topic?
http://www.pixel2lif...showtopic=42449

#3 aega

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 04 December 2008 - 06:30 AM

i found ideal solution, but how to do that on html page? http://dasme.org/imagegal/demo/#

Edited by aega, 04 December 2008 - 12:22 PM.


#4 austen

    P2L Jedi

  • Members
  • PipPipPip
  • 910 posts
  • Location:Montana, US
  • Interests:Web design, snowboarding (lots of it), Computer science related.

Posted 04 December 2008 - 08:47 PM

I don't have time to explain too in-depth, but i will explain the general process for you so you can figure it out on your own.

So... you have an html image tag that holds the image (i.e. <img src="someimage.jpg" id="img_container" />), give it an id, say "img_container", then you've got a text link, or a thumbnail link, and on this link, you'll use the onclick option of the html <a href> tag. In the onclick, you'll call a javascript function, which i will try to explain.

Let's say this function is called swap.

so you'd have.... <a href="someurl" onclick="swap(img_container,'path/to/new/image.jpg'); return false">

and your swap function will look a little something like this:

function swap(element, path){
//get element by id

//then do element.src = path


//now you've got the basics.
}


}

Good luck.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users