Support the ongoing development of →
Input Database Views
Last updated 10 months ago.

The error is in the route, I should create parameter route like:

Route::get('dropdowns/stations/{id}', '[email protected]');

And modify a bit the jquery script and DropDownController:

public function getStations($id)
		$stations = Station::where('basin_id', '=', $id)->get();
		$options = array();

		foreach ($stations as $station) {
			$options += array($station->id => $station->name);

		return Response::json($options);

AJAX call:

<script type="text/javascript">
	$(document).ready(function() {
		$("#basin_id").change(function() {
			$.getJSON("../dropdowns/stations/" + $("#basin_id").val(), function(data) {
				var $stations = $("#station_id");
				$.each(data, function(index, value) {
					$stations.append('<option value="' + index +'">' + value + '</option>');
			$("#station_id").trigger("change"); /* trigger next drop down list not in the example */
Last updated 10 months ago.

Why don't you use Select2 , it has ajax support and I use it in my projects as well.


What is Select2?


Sign in to participate in this thread!

Full Stack Europe

Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.