Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    May 2008
    Posts
    65
    Member #
    16874
    Hey everyone,
    I want to make my list of items link to it corresponding image. I have one div with my list and another div I want the image to go into. It seems I need .js to do this. Is that right? If so is there a script I could use?

    Thanks so much

  2.  

  3. #2
    Member Breezy's Avatar
    Join Date
    Sep 2009
    Posts
    51
    Member #
    19824
    just call this function in the onclick property of your list links:
    function refreshPic(filename){
    document.getElementById("yourImageID").src=filenam e;
    }
    so the onclick parameter would need to look like:
    onclick="javascript:refreshPic('myfilename');"
    easy enough?
    Utah Web Design { Pimpin(it); } - ENJOY yo-self

  4. #3
    Member
    Join Date
    May 2008
    Posts
    65
    Member #
    16874
    Hey Breezy, thanks for replying. I wish it were that easy for me, but I have long way to go. Not quite understanding where the code goes on the page. Here is the link http://bluecat.x10hosting.com/work.php#

    If you could help, I would be really grateful.

  5. #4
    Member Breezy's Avatar
    Join Date
    Sep 2009
    Posts
    51
    Member #
    19824
    okies... yeah that wasn't what I meant at all - :-P but don't worry, you'll get it :-)
    to fix it, just change this: (everywhere you've done it - and if you're using php vars to provide the filenames, you can just substitute the var where I have the filename - but keep the single quotes! - because JS will see it as the actual string, not the var)
    <a href="#" onclick='images/delmonico-website.jpg'>Web Design</a>
    to this:
    <a href="#" onclick="changePicTo('images/delmonico-website.jpg');">Web Design</a>
    then your <img> tag will need to look like this:
    <img id="myIMG" src="images/delmonico-website.jpg" width="200" height="134" alt="delmonico website" />

    and make sure to stick this between your <head> and </head> tags:
    <script type="text/javascript">
    function changePicTo("pic"){
    document.getElementById("myIMG").src = pic;
    }
    </script>
    ...and that will do it. Did you get what I did there? (give a man a fish...)
    Utah Web Design { Pimpin(it); } - ENJOY yo-self


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

linking images to a div

Click on a term to search for related topics.
All times are GMT -6. The time now is 12:14 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com