
function swp_districtfilter () {

    var select = $('#form-input-municipality-select');
    if ( select ) {
        var options = this.formFields.municipality.options;
        var districts = [];
        $.each( this.formFields.district.options, function ( key, label ) {
            if ( $('#form-input-district-check-' + key).hasClass( 'form-checkbox-selected' ) ) {
                districts.push( key );
            }
        } );
        if ( districts.length ) {
            options = {};
            var regex = new RegExp( '<(X|' + districts.join( '|' ) + ')>' );
            $.each( this.formFields.municipality.options, function ( key, label ) {
                if ( key.match( regex ) ) {
                    options[ key ] = label;
                }
            } );
        }
        select.empty();
        select.append( '<option value="">Ort: beliebig</option>' );
        $.each( options, function ( key, label ) {
            select.append( '<option value="' + key + '">' + label + '</option>' );
        } );
    }
}

