【发布时间】:2016-10-06 08:57:14
【问题描述】:
我有 2 个 HTML 表格。我正在尝试根据第一个表中按下的链接来更改第二个表的内容。
下面是填充第一个表的代码:
$.each(tableResults, function () {
$('#table1 tbody:last-child').append('<td>' + this + '</td>');
});
下面是填充第二个表的代码:
$(document).ready(function () {
var tableName = 'databaseTable1';
$.ajax({
url: 'http://localhost/api/Dynamic?table=' + tableName,
dataType: 'Json',
success: function (tableResults) {
$.each(tableResults, function (index, value) {
if ($('#table2 th:last-child').length === 0) {
$('#table2 thead').append('<th>' + value + '</th>');
} else {
$('#table2 th:last-child').after('<th>' + value + '</th>');
}
});
}
});
});
如您所见,表格是动态填充的。我需要知道如何将第一个表中的每个值转换为将变量tableName 更改为所选值的链接。
然后页面应刷新并显示所选表中的数据。如果它有助于我的程序有一个F# 后端。
另外,有人知道我如何将tableNames 默认值设置为table1 中的第一个值。
任何帮助将不胜感激。
【问题讨论】:
标签: javascript jquery html mysql ajax