...

View Full Version : onclick event



darknoobie
07-17-2011, 07:38 PM
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.


<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.


<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?

devnull69
07-18-2011, 03:30 PM
So basically you want to open the Ibox when you select a value from the dropdown?

Try this:


<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).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum