0
我正在爲我的實習製作一個網站,並且遇到了一個問題。從我的數據庫中檢索數據到我的文本框中。如果可能的話,每個人都有自己的信息。例如;我有一個約翰的文本框,他有一個名字和電子郵件。傑克也有一個名字和電子郵件。兩者都需要從數據庫中選擇並放入表單中。這是一種可以對人員信息進行更改的表格。您可以自己看到網站here。點擊「Wijzig」按鈕查看我的意思。如何填充我的文本框?
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<tr>
<td width="100">
<div id="flip">
<img src="images/ik.jpg" class="circular" width="100px" height="100px">
<td width="350px">
<label for="luca" style="width: 280px;">Luca Fraser</label>
<div id="panel" style="display: none;">Geboortedatum: 30-12-1997
<br>Email: [email protected]
<br>Woonplaats: Winterswijk
</div>
</td>
</div>
</td>
<td>
<label for="luca">Voorzitter</label>
</td>
<td style="border-color: transparent;">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModalNorm" style="background-color: #42a5f5; border-color: #42a5f5; margin-left: 20px;">Wijzig
</button>
<div class="modal fade" id="myModalNorm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">×</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
Wijzigen
</h4>
</div>
<!-- Modal Body -->
<div class="modal-body">
<form role="form">
<div class="form-group">
<label for="exampleInputEmail1">Voornaam</label>
<input type="email" class="form-control" id="exampleInputEmail1" value="Here needs to get a input value, look at line 247 to see where it needs to be." />
</div>
<div class="form-group">
<label for="exampleInputEmail1">Achternaam</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Janssen" />
</div>
<div class="form-group">
<label for="exampleInputEmail1">Email</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="[email protected]" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Telefoonnummer</label>
<input type="text" class="form-control" id="exampleInputPassword1" placeholder="0612345678" />
</div>
<div class="form-group">
<label for="exampleInputEmail1">Functie</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Voorzitter" />
</div>
</form>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
Close
</button>
<button type="button" class="btn btn-primary">
Save changes
</button>
</div>
</div>
</div>
</div>
</td>
<td style="border-color: transparent;">
<button type="button" class="btn btn-danger" onclick="myFunction()">Verwijder</button>
</td>
</tr>
您需要將從數據庫收集的值傳遞給Javascript,並用Javascript填充。 – Max
嘗試發送一個ajax請求到數據庫並根據用戶填寫表單或者如果數字是記錄顯示爲小然後加載頁面加載的值 –
您可以使用ajax來看看這個-http://blog.teamtreehouse .com/beginners-guide-to-ajax-development-with-php –