Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Drop Down Images with Hyperlink Question

    Hi I was wondering if someone had a minute to show me how I might be able to match up changing hyperlinks to the below drop-down images selection script.

    Thanks so much.

    Code:
    <html>
    <head>
    
    <script>
    
    var Path='images/';
    
    function CngColor(obj){
    index=obj.selectedIndex;
    if (index<1){document.getElementById('Img1').src="images/Blank.gif"; return; }
    document.getElementById('Img1').src=Path+obj.options[index].id;
    }
    
    </script>
    
    </head>
    
    <body>
    
    <select onchange="CngColor(this);" >
    <option >Select</option>
    <option id="image1.jpg" value="Image 1" >Image 1</option>
    <option id="image2.jpg" value="Image 2" >Image 2</option>
    <option id="image3.jpg" value="Image 3" >Image 3</option>
    </select>
    
    <a href="#">
    <img id="Img1" src="images/Blank.gif" width=100 height=100 >
    </a>
    
    <script type="text/javascript">
      window.onload=
        function() {
          var sels = document.getElementsByTagName('select');
          CngColor(sels[0]);
          CngColor2(sels[1]);
          CngColor3(sels[2]);
        };
    </script>
    
    </body>
    
    </html>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Man, is that code overly complicated!

    Anyway...

    Is this really the same as your other question about "My Uncle" et al.???

    If so:
    Code:
    <select 
      onchange="if ( this.selectedIndex!=0 ) window.open(this.options[this.selectedIndes].value,'POPUP','width=200,height=400);">
    <option >Select</option>
    <option value="image1.jpg">Image 1</option>
    <option value="image2.jpg">Image 2</option>
    <option value="image3.jpg">Image 3</option>
    </select>

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yeah it was hanks again OP!


  •  

    Posting Permissions

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