I'm having a hard time populating a drop-down that contains data from different columns. I am able to do it per row, but not per column from a single row.
tbl_salary_matrix
id | position_id | year_experience | salary_minimum | salary_median | salary_maximum
1 1 below 3 $1,000 $1,500 $2,000
I want the three salary column to be populated to a drop-down. This is the current code I'm using to create a dynamic drop-down getting the data from each row.
Controller
public function getSectionList(Request $request) {
$getSection = SectionModel::where("department_id", $request->department_id)->pluck('section_name', 'id');
return response()->json($getSection);
}
Web.php
Route::get('get-section-list-employee','EmployeeController@getSectionList');
Blade.php
<div class="form-group col-md-12 row">
<label class="col-md-4 col-form-label text-md-right"></label>
<div class="col-md-6">
<select id="department" name="department" class="form-control">
<option value="0">Please Select Department</option>
@foreach ($getDepartment as $id => $department)
<option value=""></option>
@endforeach
</select>
</div>
</div>
<div class="form-group col-md-12 row">
<label class="col-md-4 col-form-label text-md-right"></label>
<div class="col-md-6">
<select id="section" name="section" class="form-control">
</select>
</div>
</div>
Javascript
<script type="text/javascript">
$('#department').change(function(){
var departmentID = $(this).val();
if(departmentID) {
$.ajax({
type:"GET",
url:"?department_id="+departmentID,
success:function(res){
if(res) {
$("#section").empty();
$("#section").append('<option>Please Select Section</option>');
$.each(res,function(key, value){
$("#section").append('<option value="'+key+'">'+value+'</option>');
});
} else {
$("#section").empty();
}
}
});
} else {
$("#section").empty();
}
});
</script>
How do I convert this code in order to have a drop-down that gets data from all three columns (salary_minimum, salary_median, salary_maximum) that are in a single row?
Thank you very much and have a great day ahead!
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2I32udM
via IFTTT
Aucun commentaire:
Enregistrer un commentaire