json - 如何使用条件过滤表中的行
问题描述
<script>
$(document).ready(function() {
$("#tabledivss").hide();
$("#showTable").click(function(event) {
var frmdt = $("#fromDate").val();
var nam = $("#name").val();
$.get('studenttable', function(responseJson) {
if (responseJson != null) {
$("#countrytabless").find("tr:gt(0)").remove();
var table4 = $("#countrytabless");
$.each(responseJson, function(key, value) {
if(nam === "Mithra")
{
var rowNew = $("<tr> <td></td><td></td><td></td><td></td></tr>");
rowNew.children().eq(0).text(value['CODE']);
rowNew.children().eq(1).text(value['Our_ID']);
rowNew.children().eq(2).text(value['Name']);
rowNew.appendTo(table4);
}
});
}
});
});
});
</script>
<select id="name">
<option value="01"> Mithra </option>
<option value="02"> Ravi </option></select>
<table id="tabledivss">
<tr>
<th scope="col">Code</th>
<th scope="col">ID</th>
<th scope="col">name</th>
<th scope="col">Location</th>
</tr></table>
我使用此代码根据下拉列表值过滤行。仅根据 if 条件在行中显示密特拉值。我不知道在获取数据时如何过滤行。
解决方案
推荐阅读
- r - 在 R 中绘制伦敦地图上的邮政编码
- grafana - 如何以 json 或任何其他格式访问 Graphite RAW 数据?
- google-polyline - 如何获取折线中所有点的经度和纬度值
- gstreamer - GStreamer 教程 3 无法链接视频板
- python-2.7 - 如何从 .txt 文件中提取数据(时间)?
- javascript - 将鼠标悬停事件传递给下层,同时覆盖具有菜单的 div 元素保持可点击状态
- android - 不能设置外键为空,多个外键
- python-2.7 - 如何检查 Python 字典列表中是否存在键/值?
- z3 - 如何使用 c++ 在 z3 中为现有声明的函数添加新约束?
- javascript - 在不使用名称标签的情况下为不同的输入创建通用的 onChange() 函数