An alternative... var destOpts = $('#hotel_destinazione option'); $('#hotel_paese').change(function(){ var sel_val = $(this).val() || ''; destOpts.each(function(){ var me = $(this); me[sel_val=='' || me.is('.'+sel_val) ? 'show' : 'hide'] (); }); });
On May 9, 11:57 am, andrea varnier <[EMAIL PROTECTED]> wrote: > Hi :) > what is the fastest way to edit a <select> item? > I need to show some <option>'s and hide some others, depending on the > value of another select. > let's say if the user selects a country for his holiday, in the > '#hotel_paese' select, the '#hotel_destinazione' select will show only > the hotels of that country. > problem is that the '#hotel_destinazione' select has already got its > values, so I'm using the class attribute to keep track of the country. > so if, say, egypt has code '001', then sharm el sheik, abu simbel, > aswan, luxor, and so on will all have class '001'. > > the .show() and .hide() methods seem to be a little too slow. > or maybe is my code? > > // this is the select > $('#hotel_paese').change(function(){ > var $this = $(this); > var sel_val = $this.val(); > $('#hotel_destinazione option').show() > if (sel_val != '') $('#hotel_destinazione option').not('.' + > sel_val).hide(); > > }); > > thank you very much :)