<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>
{{-- 在資料庫中,有一個名為 rooms 的表。我想顯示 table(room) 中的所有房間詳細資訊--}}
uj5u.com熱心網友回復:
您應該使用以下代碼更改 PHP 代碼
<div class="col-md-12">
<div class="form-group first">
<label >Date_reservation</label>
<input type="date" name="date_res" id="date_res">
</div>
</div>
<div class="row">
<div>
<div class="form-group first">
<label >Type_salle</label>
<select name="code_salle" id="code_salle">
<option>STD1</option>
<option>STD2</option>
<option>STD3</option>
<option>STD4</option>
</select>
</div>
</div>
</div>
之后,您可以使用 onchange 函式從資料庫中獲取房間詳細資訊(fetch_room_data.php,用于從資料庫中獲取房間表詳細資訊)。在這里,我將提供一個示例代碼
$('#date_res').on('change', function()
{
$.ajax({
url:"fetch_room_data.php",
method:"POST",
success:function(data)
{
$('#code_salle').html(data);
}
});
});
uj5u.com熱心網友回復:
您將需要 Javascript 和 API 路由,因為您不能僅將 html 與您的資料庫連接起來,這不是它的作業方式。
另一種選擇是使用刀片(laravel 的模板引擎)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/478136.html
標籤:javascript php html 阿贾克斯 拉拉维尔
下一篇:如何在ajax中發送資料和請求
