Issue
I have data in an array that contains hotels' names with their id. I want to place them in my select where I will display only the city an grab the id to do ajax and display rooms name. The problem is it is displaying both the name of the hotel and the id array in my dropdown. this is my controller.
foreach ($hotel as $nam ){
$hotel_nam[]=$nam->id;
$hotel_nam[]=$nam->hotel_name;
}
return $hotel_nam;
this is my drop down
{!! Form::select('hotel_name',$hotel_nam,'S', array('style'=>' Border:none; ', 'id' => 'hotel_id', 'onchange'=>"showRooms(this.value)"));!!}
Solution
$hotelLists = [''=>'--Select Hotel--'];
foreach ($hotel as $nam) {
$hotelLists[$nam->id] = $nam->hotel_name;
}
{!! Form::select('hotel_name',$hotelLists,'', array('style'=>' Border:none; ', 'id' => 'hotel_id', 'onchange'=>"showRooms(this.value)"));!!}
Answered By - Md Abdul Awal
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.