mardi 7 août 2018

display value in textbox respective to selected value from drop down

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?

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=""></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> 



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire