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 2 of 2

Thread: onclick event

  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onclick event

    Hello forum,
    My name is juan and recently started html programming. I have a web page with a drop box with the name of states.
    Code:
    <option value="">Alabama</option>
    <option value="">Alaska</option>
    I can add a onclick="code here" to the tag so that when the drop box alabama is selected it triggers the onclick event.

    Im using Ibox in order to have a image of the state open.

    Code:
    <a href="images/large/image_1b.jpg"  rel="ibox" title="alabama at 1024x450!"><img 
    src="images/small/image_1.jpg" alt=""/></a>
    the above is a <a> link tag correct? How do I go bout adding the above code into the onclick event?

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    So basically you want to open the Ibox when you select a value from the dropdown?

    Try this:
    Code:
    <option value="" onclick="openIBox(1);">Alabama</option>
    ...
    <a id="image1" href="images/large/image_1b.jpg"  rel="ibox" title="alabama at 1024x450!"><img 
    src="images/small/image_1.jpg" alt=""/></a>
    
    
    Javascript:
    function openIBox(myIndex) {
       document.getElementById('image'+myIndex).click();
    }
    You should give all your <a> links a unique id for this (like image1, image2 etc).


  •  

    Posting Permissions

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