Stumped with selectors

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Lonestarjack
Forum Commoner
Posts: 31
Joined: Tue Nov 11, 2008 7:13 am
Location: Texas

Stumped with selectors

Post by Lonestarjack »

I want to keep the img hidden until an option is selected. Seems simple enough.
It is hidden on the load, but I can't get it to open on the select.

<script type="text/javascript">
$(document).ready(function() {
$("#pic").hide()
});

$("#dropdown.option :selected")(function() {
$("#pic").show()
});
</script>
...
echo '<td><select id="dropdown" onselect="setit(this.options[this.selectedIndex].value)">';
...
echo '<img src="arrow_down.gif" id="pic" width="32" height="30" border="0" onClick="popit()">';
Last edited by califdon on Mon Mar 26, 2012 1:59 pm, edited 1 time in total.
Reason: Moved to Javascript forum by moderator.
Gopesh
Forum Contributor
Posts: 143
Joined: Fri Dec 24, 2010 12:48 am
Location: India

Re: Stumped with selectors

Post by Gopesh »

Hi,didn't get the problem well..I made a Jsfiddle check this http://jsfiddle.net/zkMBw/.Hope it helps to solve the problem.
User avatar
Lonestarjack
Forum Commoner
Posts: 31
Joined: Tue Nov 11, 2008 7:13 am
Location: Texas

Re: Stumped with selectors

Post by Lonestarjack »

Thanks
Works fine. I thought that I had tried your solution before, but I must have messed it up somehow.
Thanks again
Gopesh
Forum Contributor
Posts: 143
Joined: Fri Dec 24, 2010 12:48 am
Location: India

Re: Stumped with selectors

Post by Gopesh »

Welcome..Good luck.
Post Reply