I want to get the value of my Select Dropdown list from my view to my controller
Is there any way i can get this? :(
Here's my dropdown view
{{ Form::select('status', ['All', 'Absent', 'Late', 'Others']) }}
Here's where i want to condition my selected value
public function filterSummaryStudent()
{
if(Input::has('status') == 'All')
{
(other codes here)
}
I've been getting a blank page when i call this.. Please help. Thank you!
You must specify the value of select dropdown as associative arrays if you want to check the value as a string. Right now your select dropdown code the value is define using numeric index of the array. When you check the Input::has('status') == 'All', of course laravel will return false.
Your code
{{ Form::select('status', ['All', 'Absent', 'Late', 'Others']) }}
HTML Output
<select name="status">
<option value="0">All</option>
<option value="1">Absent</option>
<option value="2">Late</option>
<option value="3">Others</option>
</select>
Correct code
{!! Form::select('status', ['All' => 'All', 'Absent' => 'Absent', 'Late' => 'Late', 'Others' => 'Others']) !!}
HTML Output
<select name="status">
<option value="all">All</option>
<option value="absent">Absent</option>
<option value="late">Late</option>
<option value="others">Others</option>
</select>
If you write like the above code you can check the select dropdown like this.
if(Input::has('status') == 'All') {
// Your code
}