John Davidson

javascript - how show value of input select from database without click any button after select date?

0 comments
Message:


<div class="col-md-12">
<div class="form-group first">
<label >Date_reservation</label>
<input type="date" name="date_res">
</div>
</div>
<div class="row">
<div >
<div class="form-group first">
<label >Type_salle</label>
<select name="code_salle" >
<option>STD1</option>
<option>STD2</option>
<option>STD3</option>
<option>STD4</option>
</select>
</div>
</div>
</div>


{{-- In the database, there is a table named rooms. I want to display
all room details from the table(room) --}}




My Answer:
You can achieve this by using the `change` event in JavaScript. Here's an example code snippet to show the value of the selected input select from the database without clicking any button after selecting the date:

html



Get Selected Value










In this code snippet, we are adding an event listener to the `selectInput` element for the `change` event. When the user selects an option from the dropdown, the event listener will trigger and log the selected value to the console. You can then make an AJAX call to fetch data from the database based on the selected value and display it on the page.

Rate this post

5 of 5 based on 7294 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us