This is almost entirely a javascript thing, using ajax to populate the location dropdown. On the server side, you'll need to write a small function that takes a customer id, and returns locations for them. I don't know what database wrapper you're using, so you'll have to obviously change a few things to make it work, but it'll end up looking roughly like: (I'm freehanding this code without trying any of it, so there might be obvious syntax errors fyi)
# with your imports... from flask import jsonify # with your other routes... @route("/location/:customer_id") def lookup_location(self, customer_id): locations = self.db.Locations.find_by_customer(customer_id) return jsonify(locations)Then, in js, create an event handler to watch for change events, and update the locations accordingly. With jquery, it'd look a little like:
<script type="text/javascript"> $(function() { $("#customer_dropdown").change(function() { var customer_id = $(this).val(); $.ajax( { url: "/location/", type: "post", dataType: "json", data: { customer_id: customer_id } }) .done(function(data) { // clear any locations currently there $("#location_dropdown").html(""); for (var ndx = 0; ndx < data.length; ndx++) { var item = data[ndx]; var option = document.createElement("option"); option.value = item["value"]; option.text = item["description"]; $("#location_dropdown").append(option); } }); }); }); </script>