Posted inTechnology / Ajax / JavaScript / jQuery / Laravel / Mysql / Mysqli / php / Programming

Select DropDown Option Selected In Laravel

Today, We want to share with you Select DropDown Option Selected In Laravel.In this post we will show you dynamic select option in laravel, hear for how to show selected value in dropdown in laravel 7/6 we will give you demo and example for implement.In this post, we will learn about Select Selected value of a dropdown in laravel 7/6 with an example.

Select DropDown Option Selected In Laravel

There are the Following The simple About Select DropDown Option Selected In Laravel Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel select option selected from database, so the Set selected option in dynamically created drop down menu in Laravel for this example is following below.

Example 1: laravel get selected value from dropdown in controller

// Controller
public function index()
{
    $prioritys = Prioritys::all();
    $selectedPriority = User::first()->role_id;

    return view('my_view', compact('prioritys', 'selectedPriority');
}

And then in your view


Example 2 : laravel select option selected from database

// Controller

public function index()
{
    $prioritys = Prioritys::lists('name', 'id');
    $selectedPriority = User::first()->role_id;
    return view('my_view', compact('prioritys', 'selectedPriority');
}

//In view
{!! Form::select('role_id', $prioritys, $selectedPriority, ['class' => 'form-control gstspan') !!}

Example 3: Select Selected value of a dropdown in laravel

//in controller
$oldproducts = Request::old('products');

//Laravel Blade view files
@foreach ($allproducts as $key => $value)
  $selected = '';
  @if( $value == $oldproducts )
    $selected = 'selected="selected"';
  @endif
  
@endforeach
Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Selects DropDowns Option Selected In Laravel.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype