I've a dropdown for Book Name. The user has to select the required Book Name from the drop down.As the user selects the book name, I have to show the price of that book in read only textbox. The values are retrieved from database. How can I do this? It is not duplicate question. I want to know how to get the associated value selected in the drop down menu.
controller method
public function getBooks()
{
return Book::all('BookName', 'BookID', 'Price');
}
view page
<div class="form-group" style="padding-left: 5%;">
<label>Book Name</label><span class="required">*</span>
<select class="js-example-basic-single form-control" name="sel_Book">
@foreach ($books as $data)
<option value="{{ $data->BookID }}">{{ $data->BookName }}</option>
@endforeach
</select>
</div>
<div class="form-group" style="padding-left: 5%;">
<label>Book Price</label><span class="required">*</span>
<input type="text" readonly="readonly" class="form-control"/>
</div>