Skip to content Skip to sidebar Skip to footer

Jquery - Select Menu - Onchange Reevaluate Value

I have a select menu with a list of country names. I'm using jquery to get the value of the currently selected option. I'm appending this to the url of the remote source file tha

Solution 1:

You can use change event handler:

$('#from_country').change(function(){
  var val = this.value;
  $("#city").autocomplete({
    source: "json-list.php?country=" + val,
    minLength: 3,
    select: function(event, ui) {
      $('#from_zip').val(ui.item.postal_code);
    }
  });
}).change()

Solution 2:

You can change source option after init:

$("#city").autocomplete( "option", "source", /* new source path */ );

Post a Comment for "Jquery - Select Menu - Onchange Reevaluate Value"