<div class="well well-sm">
New Filter
<select id="filtertype">
<option value="sector">Sector</option>
<option value="geography">Geography</option>
<option value="keyevent">Key Event</option>
<option value="jobarea">Functional Area</option>
</select>
<input type="text" id="searchfilter" placeholder="Start typing..." style="width:20em">
<input type="button" class="button" value="Add filter">
</div>
<input type="hidden" name="filters">

<script>
$(document).ready(function() {
    $('#searchfilter').autocomplete({
        source: function(request, response) {

    		var type = $('#filtertype').val();
    		var url = '/ajax/filter/search/' + type + '/' + request.term;
    		
            $.ajax({
                url: url,
                success: function(data) {
                    data.forEach(function(item) {
                        item.value = item.label;
                    });
                    response(data);
                }
            });
        }
    });
	});
</script>
<div class="well well-sm">
New Filter
<select id="filtertype">
<option value="sector">Sector</option>
<option value="geography">Geography</option>
<option value="keyevent">Key Event</option>
<option value="jobarea">Functional Area</option>
</select>
<input type="text" id="searchfilter" placeholder="Start typing..." style="width:20em">
<input type="button" class="button" value="Add filter">
</div>
<input type="hidden" id="filters" value='[{}]'>

<script>
$(document).ready(function() {
	function updateTags()
	{
	}
	
    $('#searchfilter').autocomplete({
        source: function(request, response) {

    		var type = $('#filtertype').val();
    		var url = '/ajax/filter/search/' + type + '/' + request.term;
    		
            $.ajax({
                url: url,
                success: function(data) {
                    response(data);
                }
            });
        },
        select: function(event, ui) {
        	$('#searchfilter').val(ui.item.label);
        	var json = $('#filters').val();
        	var currentFilters = jQuery.parseJSON(json);
        	currentFilters.push(ui.item);
        	$('#filters').val(JSON.stringify(currentFilters));
        	updateTags();
        	event.preventDefault();
        }
    });
});
</script>
Set values in hidden field
Set values in hidden field
