In my blade I have the following dropdown list
{!! Form::select('plans', $named_plans, null,['class' => 'form-control'] ) !!}
which is populated by a list named $named_plans
passed by the controller. So far so good.
I need to take the value selected by the user from the dropdown and add it as a parameter to a URL. I can't figure out (and the LaravelCollective documentation is minimal at best) how to append the selected string to a URL (or route) and redirect the user there. Similar to how a dropdown menu works.
For instance, if the user selected "foo"
from the dropdown, I want to send them to mylaravelsite/public/displaypage/foo
. I have a route that will process displaypage/{foo}
just fine if I could just code for the redirect.
Any suggestions would be very helpful.
I'm using Laravel 5.5 with PHP 7 on XAMPP
First take the value of selectbox option and add the attribute action to the form
$('#selectboxid').change(function(){
var optionSelected = $("option:selected", this);
optionValue = this.value;
$('#idoftheform').attr('action','public/displaypage/'+optionValue);
});