2

Im trying to be able to be redirected to the page that the post is on when i select a post from a dropdown list of all my posts.

at the moment i have managed to populate the list with all of the post titles and i have added a link in the form of a to each element in the list but when i click on one of the elements nothing happens.

here is the code i use to populate the list:

<div class="col-md-10">
    <select class="form-control" id="post" name="post" required focus>
        @foreach($post as $posts)
            @if($posts->user_id == Auth::user()->id)
                <option value="/posts/{{$posts->id}}" selected>
                    <a href="/posts/{{$posts->id}}">
                        {{$posts->title}}
                    </a>
                </option>
             @endif       
         @endforeach
     </select> 
</div>

the page that i need to be redirected is in the following format:

/posts/id

where the id is the post id

How do i make this work?

es915
  • 137
  • 3
  • 11
  • Does this answer your question? [Load page on selection from dropdown form](https://stackoverflow.com/questions/10175445/load-page-on-selection-from-dropdown-form) – Peppermintology Dec 28 '20 at 17:51
  • No, i tried that and it just messed everything up as in instead of there just being one list there is now one list for every element and – es915 Dec 28 '20 at 18:05

1 Answers1

1

You have to use like this

<a class="dropdown-item" href="{{url('')}}/posts/{{$posts->id}}">{{$posts->title}}</a>
           
A.A Noman
  • 5,244
  • 9
  • 24
  • 46