Skip to content Skip to sidebar Skip to footer

Update Dropdown Values Based On Another Dropdown - Jquery

Here is the fiddle I have two dropdown items in my HTML. where from and where to You have to chose where from before the where to is filled with options. The array containing the

Solution 1:

A couple of things,

First, you need to change the $("#travel_from").on( "selectmenuchange", ... to $("#travel_from").on( "change", ...

You'll also need to clear the travel_to cities each time you do this event, like so

$('#travel_to').find('option').remove();

If you want the travel_to dropdown to be disabled at first, you'll need to give the select the disabled property in your HTML, then remove it when you do the change event.

HTML

<select id="travel_to" disabled>

JS

$('#travel_to').prop('disabled', false);

That's it. This should be pretty much what you're looking for, here's a complete fiddle

Post a Comment for "Update Dropdown Values Based On Another Dropdown - Jquery"