Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery dropdown options in laravel

public function get_by_country(Request $request)
{
    abort_unless(Gate::allows('city_access'), 401);

    if (!$request->country_id) {
        $html = '<option value="">'.trans('global.pleaseSelect').'</option>';
    } else {
        $html = '';
        $cities = City::where('country_id', $request->country_id)->get();
        foreach ($cities as $city) {
            $html .= '<option value="'.$city->id.'">'.$city->name.'</option>';
        }
    }

    return response()->json(['html' => $html]);
}
Source by blog.quickadminpanel.com #
 
PREVIOUS NEXT
Tagged: #jquery #dropdown #options #laravel
ADD COMMENT
Topic
Name
9+4 =