RonnieT
RonnieT

Reputation: 2203

Dropdown not updating when selected via Ajax

I have two select dropdowns, regions and towns. If the region is selected, it updates the towns dropdown with the appropriate towns for that region using Ajax.

I am trying to use an imagemap to select the dropdown for region, which should update the towns, but it is not. The value for region dropdown gets selected but the ajax does not fire to update towns. All works fine if not using the imagemap. Is the image map select jQuery below not actually updating the select box the way I think it is? Any ideas?

    //ImageMap Selectors
    $('area', '#regionmap').click(function(){
      $("#region").val($(this).attr('alt'));
    });

Upvotes: 1

Views: 325

Answers (1)

gilly3
gilly3

Reputation: 91467

The onchange event is not fired when an option is selected programmatically. Trigger the event manually by tacking on a call to .change().

$("#region").val($(this).attr('alt')).change(); 

Upvotes: 1

Related Questions