I'm trying to pass a selected value in a dropdown from my view to my controller so i can make a query later.
Here is my view with the select object:
<Select class="selectsector" id="ColumnType" name="ColumnType">
<option value=""> Select something </option>
<option value=""> option 1 </option>
<option value=""> option 2 </option>
</select>
Then according to documentation and a lot of answer/examples i'm trying to get the value from the select on this line:
My route:
Route::get('kitysoftware/ColumnType/{ColumnType}', [
"uses" => 'SubSectorsBPIsDataController@TrendFilter',
"as" => 'trend'
]);
My controller:
public function TrendFilter($ColumnType)
{
$SelectedTrend = DB::table('SubSectorsBPIsData')->select('SectorID', 'ColumnType')->where('ColumnType', $ColumnType)->get();
echo $selectedTrend; //or whatever else i want to do
}
Error I keep getting: Undefined variable: ColumnType (View: ... I have tried to change several variables names in that line: *Where does it comes from that undefined variable: $ColumnType ? I'm not reloading the page since i want to collect several dropdowns values and then make the query. Not sure if i got the right approach, maybe there is a better way to make it work. JavaScript maybe?
Thanks in advance.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire