[jQuery] Re: Select box show/hide

2007-10-08 Thread Chris Jordan
Karl, I was thinking that the ids seemed unnecessary too, but then I thought that maybe he'd want to show only a subset of the items rather than all or nothing. Chris On 10/8/07, Karl Swedberg <[EMAIL PROTECTED]> wrote: > > Here is one way you could do it, based on the index of the options and >

[jQuery] Re: Select box show/hide

2007-10-08 Thread Karl Swedberg
Here is one way you could do it, based on the index of the options and divs: $(document).ready(function() { var $optionDivs = $('div[id^=option]').hide(); $('select').change(function() { var i = $('option', this).index( $(':selected')[0]); $optionDivs.h

[jQuery] Re: Select box show/hide

2007-10-08 Thread Josh Nathanson
You could create a common function to figure out which div to open, then bind it to the appropriate elements: $("img.changediv").click(showfunc); //bind to images with class "changediv" $("#selectid").change(showfunc); // bind to specific select element var showfunc = function() { if ($(t

[jQuery] Re: Select box show/hide

2007-10-08 Thread Chris Jordan
Also, I just noticed this code: $(document).ready(function() { // (hide the divs on initial view) $('#option-1').hide(); $('#option-2').hide(); $('#option-3').hide(); $('#option-4').hide(); $('#option-5').hide(); $('#option-6').hide(); $('#option-7').hide(); // (need help figuring out how

[jQuery] Re: Select box show/hide

2007-10-08 Thread Chris Jordan
bombaru, I had just helped another user with almost this same question. I'm lazy, so check out this short thread . He was doing things on a click, but you could do them on the change