獲取已選中checkbox所在行其餘列的值

//經過table的id獲取已選中checkbox的當前行第n列的值,並組合成字符串返回spa

function getTDText1(tableId, chkName, n) {字符串

var rows = $(tableId).rows;get

var objs = document.getElementsByName(chkName);it

var temp = "";io

for (var i = 0; i < objs.length; i++) {table

if (objs[i].checked) {function

var r = objs[i].parentElement.parentElement.rowIndex;class

if (temp == "") {checkbox

temp = rows[r].cells[n].innerText;tab

} else {

temp += "," + rows[r].cells[n].innerText;

}

}

}

return temp;

}

 

//經過已選中checkbox的id獲取當前行第n列的值,並組合成字符串返回

function getTDText2(chkId, n) {

var temp = "";

var ids = chkId.split(",");

for (var i = 0; i < ids.length; i++) {

var tr = $(ids[i]).parentElement.parentElement;

if (temp == "") {

temp = tr.cells[n].innerText;

} else {

temp += "," + tr.cells[n].innerText;

}

}

return temp;

}

相關文章
相關標籤/搜索