Laravel Edit DropDown Option Seleted Example – Technology

Laravel Edit DropDown Option Seleted Example – Technology

In this post we will give you information about Laravel Edit DropDown Option Seleted Example – Technology. Hear we will give you detail about Laravel Edit DropDown Option Seleted Example – TechnologyAnd how to use it also give you demo for it if it is necessary.

Today, We want to share with you Laravel Edit DropDown Option Seleted Example.In this post we will show you laravel 5.7 get selected value from dropdown in controller, hear for how to show selected value in dropdown in laravel 5.7 using ajax we will give you demo and example for implement.In this post, we will learn about How to get by default select value in dropdown in Edit mode laravel 5.7 with an example.

Laravel Edit DropDown Option Seleted Example

There are the Following The simple About Laravel Edit DropDown Option Seleted Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel 5.7 select option selected from database, so the laravel 5.7 get selected value from dropdown for this example is following below.

Example 1: Laravel edit select option values

Laravel Controller

public function edit($id)
{
    $suggestions_datas = DB::table('suggestions')->where('id', $id)->get();
    $categories = DB::table('categories')->whereNull('deleted_at')->pluck("name","id");
    return view('suggestions.edit',compact('suggestions_datas','categories'));
}

Laravel Blade file

<div >
    <label  for="suggestion_title">Applications's</label>
    <select  name="suggestion_app" id="suggestion_app" required="" autofocus="">
    @foreach ($categories as $key => $value)
        <option value="{{ $key }}" {{$suggestions_datas[0]->categories_id == $key ? "selected" : "" }}>{{ $value }}</option>
    @endforeach
    </select>
</div>

Example : 2 laravel 5.7 get selected value from dropdown

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

<div >
    <label  for="inputDefault">Employee Types</label>

    <select name="emp_types"  name="emp_types" id="inputDefault">
    <option @if(old('emp_types',$emp_types) == 'Pending') selected @endif >
        Pending
    </option>
    <option @if(old('emp_types',$emp_types) == 'Completed') selected @endif >
        Completed
    </option>
    </select>
</div>

where simple $emp_types is coming from your model

Another must read:  Check and Uncheck all Multiple Checkbox using jQuery

Example : 3 Select DropDown Option Seleted In Laravel

Laravel Controller

public function index()
{
    $teams = Teams::all();
    $selectedTeam = User::first()->role_id;

    return view('my_view', compact('teams', 'selectedTeam');
}

And then in your view

<select  name="role_id">
    @if ($teams->count())
        @foreach($teams as $role)
            <option value="{{ $role->id }}" {{ $selectedTeam == $role->id ? 'selected="selected"' : '' }}>{{ $role->name }}</option>    
    @endif
</select>
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 Laravel Edit DropDown Option Seleted Example.
I would like to have feedback on my onlinecode 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.

Another must read:  Convert JavaScript Array to JSON Example

Hope this code and post will helped you for implement Laravel Edit DropDown Option Seleted Example – Technology. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

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

  +  67  =  69

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US