我需要帮助。我有一张动态表:
while (result.next()) {
out.write("<tr>");
for (int i=1; i<=columns; i++) {
out.write("<td>" + result.getString(i) + "</td>");
}
out.write("</tr>");
}
单击该表的行,需要打开新页面或窗口,表1列包含该行的数据。我该怎么办?
答案 0 :(得分:0)
你可以这样做。将事件附加到表中的每个tr。
while (result.next()) {
out.write("<tr class="table-row">");
for (int i=1; i<=columns; i++) {
out.write("<td>" + result.getString(i) + "</td>");
}
out.write("</tr>");
}
$('.table-row').on('click', function(){
var values_array = [];
var td_values = "";
var tr_children = $(this).find('td').each (function() {
values_array.push($(this).html());
});
$.each(values_array, function(value){
td_values += "value1="+ value +"&";
});
// create a query string with the values and send to a new page like this
// you can concatenate the values to the
window.location.replace("http://page?"+td_values);
});