我编写了一个 HTML 表格,显示来自 SQL 数据库的用户信息。
<table class="table table-hover">
<tr>
<th>Username</th>
<th>Password</th>
<th>Role</th>>
<th>Attribute</th>
</th>
<th>Ideas/Score</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<?php while($result=m ysqli_fetch_array($fetch)) { $usertoattrquery="SELECT * FROM usertoattr WHERE usertoattr.user_id=" .$result[user_id]; $attrfetch=mysqli_query($con,$usertoattrquery) or die ( 'could no connect with instructions'); echo "<tr><td>".$result[ "username"]. "</td><td>" .$result[ "password"]. "</td>
<td>" .$result[ "role"]. "</td><td>only for Eval</td><td>coming soon</td><td>
<a href='#editUser' role='button' class='btn' data-toggle='modal'>Edit</a> </td>
<td><button class='btn'onclick='deleteConfirm()'>Delete</button> </td></tr>"; } ?>
</table>
当有人在特定行中按下“编辑”按钮时,我希望打开一个模态,并在模态内复制该表行中的值(例如名称和密码)。
<div id="editUser" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<h3 id="myModalLabel">Edit User</h3>
User Name
<input type="text">
<br>User Password
<input type="text">
<br>User Role
<select>
<option>Evaluator</option>
<option>Observer</option>
</select>
<br>User Attribute
<select multiple>
<option>Economics</option>
<option>Software</option>
<option>Management</option>
</select>
<br>
<button class='btn btn-primary'>OK</button>
<button class='btn' data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
这怎么可能?