You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
584 B

(function( $ ) {
'use strict';
$(function() {
$( '.wpcf7-state' ).change( function() {
var $city_select = $( '.wpcf7-city' );
$city_select.prop('disabled', true);
$.getJSON(
cf7_states_cities.rest_base + '/cities',
{ state: $(this).val() },
function ( response ) {
$city_select.find( 'option:not([value=""])' ).remove();
$.each( response, function( key, city ) {
$city_select.append('<option value="' + city + '">' + city + '</option>');
} );
$city_select.prop('disabled', false);
}
);
} );
});
})( jQuery );