I am using Google Place Autocomplete in django template. I have a search bar which will show prediction for places. When users clicks the search button, I want to pass the value which is in search bar to django URL.
Below is the code
<label for="locationTextField">Location</label>
<input id="locationTextField" type="text" size="50">
<a href="{% url 'filteredcars' city %}" id= "output">Search</a>
<script>
function init() {
var input = document.getElementById('locationTextField');
var autocomplete = new google.maps.places.Autocomplete(input);
google.maps.event.addListener(autocomplete, 'place_changed', function f1() {
var place = autocomplete.getPlace();
var city = place.address_components[0].short_name;
document.getElementById("output").innerHTML = city;
});
}
google.maps.event.addDomListener(window, 'load', init);
</script>
I am able to get the city and show it in a HTML page, but I am not able to pass it as parameter in URL.
Can someone please give me any suggestions?