0

I have two select lists -

select 1 options are - Fri, Sat, Sun

select 2 options are - ...various times....

The goal - the day you select (Fri, Sat, Sun) gives a different list of times in the second select

I tried - I used jquery to hide() to hide the options of the second select based on the value of the first select.

PROBLEM - when I select the third option (Sun), the dropdown of second select is only one line, even though there are 6 items available.

Here's my jsfiddle - http://jsfiddle.net/joshuajsmith/VLuFG/

Here's my jquery: (same as in jsfiddle)

$(function(){
      $('#review_day_sel').change(function(){
          var selectedDay = $("#review_day_sel option:selected").val();
          $(".hide-option").hide();
          $("."+selectedDay).show();
      });
});

Why is this happening? Is hide() / show() the correct way to do this?

Glorfindel
  • 20,880
  • 13
  • 75
  • 99
Joshua JJ S
  • 53
  • 1
  • 6
  • Here: http://jsfiddle.net/VLuFG/2/ Updated fiddle – Ani May 19 '14 at 20:21
  • I'm not seeing the same results for Sunday, it shows 6 for me. – dcclassics May 19 '14 at 20:21
  • I can see the problem. it's in chrome – Ani May 19 '14 at 20:26
  • Check this out http://stackoverflow.com/questions/18255185/jquery-hide-not-working-in-chrome – Ani May 19 '14 at 20:27
  • More: http://stackoverflow.com/questions/47824/how-do-you-remove-all-the-options-of-a-select-box-and-then-add-one-option-and-se – isherwood May 19 '14 at 20:31
  • And more: http://stackoverflow.com/questions/1518216/jquery-remove-options-from-select The best bet might be to put your options lists in arrays for each case. – isherwood May 19 '14 at 20:31
  • Question was closed before I could post this working answer. http://jsfiddle.net/VLuFG/5/ – Popnoodles May 19 '14 at 20:41
  • Answers were closed, but this fiddle might put you on the right track. Cheers. http://jsfiddle.net/Yn7wQ/ – SteamDev May 19 '14 at 20:42
  • thank you all for your answers and quick replies - hadn't noticed that chrome's the issue - lots (surprisingly) to review here, but i think that the Popnoodles version will work quite well. Thank you! – Joshua JJ S May 19 '14 at 22:45

0 Answers0