Reputation: 219
how do i pass my two option selected id to controller via onclick and retrieved it to another blade file
here is my code
option selected 1
<select name="cu" id="cu" class="input-sm form-control" onchange="">
<option value="">{{ __('messages.select') }}</option>
@if(!empty($custList))
@foreach($custList as $cu)
<option value="{{ $cu->cu_customer_ID }}">{{ $cu->cu_customer_Shortname }}-{{ $cu->cu_customer_Name }}</option>
@endforeach
@endif
</select>
option selected 2
<select name="state" id="state" class="input-sm form-control">
<option value="">{{ __('messages.select') }}</option>
@if(!empty(request()->session()->get('stateList')))
@foreach(request()->session()->get('stateList') as $state)
<option value="{{ $state->st_state_code }}">{{ $state->st_state_desc }}</option>
@endforeach
@endif
</select>
onclick which both id value passing to controller
onclick="openNewWindow('{{ route('reporting.branchCheckBoxList', ['#cu' ,'#state']) }}')"
web route
Route::get('reporting/branchCheckBoxList/{cuid}/{stid?}','GenReportController@branchCheckBoxList')->name('reporting.branchCheckBoxList');
controller
public function branchCheckBoxList($cuid, $stid = '') {
$cuid = $cuid;
$stid = $stid;
return view('report.BranchCheckBoxList', compact('cuid','stid'));
}
my another blade view
<script>
//how do i retrieve both selected value ??
</script>
Upvotes: 0
Views: 271
Reputation: 86
My ideal is fill a placeholder for params cuid
and stid
in route
method and replace by selected value.
onclick="openNewWindow('{{ route('reporting.branchCheckBoxList', ['cuid' => '_cuid_', 'stid' => '_stid_']) }}'.replace('_cuid_', document.getElementById('cu').value).replace('_stid_', document.getElementById('state').value))"
Upvotes: 1