我将如何添加一个下拉菜单到我使用mysql的jquery表?
问题描述:
所以目前我想弄清楚如何将下拉菜单添加到我在下面发布的代码中。我搜索了互联网,但找不到一种适合我的方式,我对编码很陌生,所以对其他人来说,这种方式很难实现。我将如何添加一个下拉菜单到我使用mysql的jquery表?
<table class="table table-bordered table-striped">
<thead> <!-- add class="thead-inverse" for a dark header -->
<tr>
<th>ID</th>
<th>USERNAME</th>
<th>Crime(s)</th>
<th>Active</th>
<th>EDIT</th>
</tr>
</thead>
<tfoot>
<tr>
</tr>
</div>
</th>
</tfoot>';
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["id"].'</td>
<td class="username" data-id1="'.$row["id"].'" contenteditable>'.$row["name"].'</td>
<td class="crime" data-id2="'.$row["id"].'" contenteditable>'.$row["crime"].'</td>
<td class="activated" data-id2="'.$row["id"].'" contenteditable>'.$row["activated"].'</td>
<td><button type="button" name="delete_btn" data-id3="'.$row["id"].'" class="btn btn-xs btn-danger btn_delete">DELETE</button></td>
</tr>
';
}
$output .= '
<tr>
<td></td>
<td id="name" contenteditable></td>
<td id="crime" contenteditable></td>
<td id="activated" contenteditable></td>
<td><button type="button" name="btn_add" id="btn_add" class="btn btn-xs btn-success">ADD ACCOUNT</button></td>
</tr>
';
}
else
{
$output .= '<tr>
<td colspan="4">Data not Found</td>
</tr>';
}
$output .= '</table>
</div>';
echo $output;
?>
答
既然你提到你想下拉列表添加到您的表的激活部分,它应该包含Yes
,No
和Being Verified
,你可以更新表列是
<td class="activated" data-id2="'.$row["id"].'" contenteditable>
<select name="activated" id="activated">
<option value="Yes" '.(($row["activated"] == "Yes") ? 'selected="selected"':"").'>Yes</option>
<option value="No" '.(($row["activated"] == "No") ? 'selected="selected"':"").'>No</option>
<option value="Being Verified" '.(($row["activated"] == "Being Verified") ? 'selected="selected"':"").'>Being Verified</option>
</select>
</td>
这将允许db $row["activated"]
的值在下拉列表中自动选中。
+0
谢谢你的工作!只是我挣扎与CSS样式的按钮? –
+0
@BluqeBluqe很高兴它为你工作,不要忘记标记为答案。你可以添加一个类到'
+0
非常感谢你的帮助! –
为了明确这一点,我想补充,当你在框中单击正在积极将有几个选项,一旦点击下拉出现,您选择,然后修改和更新的选项下拉。 –
http://prntscr.com/fqt7q2 –
你在哪里试图添加下拉菜单?它应该包含什么值@ bluqe-bluqe – AceKYD