选中复选框时,将所需的行信息作为键值对存储在全局对象中
我不记得具体我以前是怎么做的,但语法类似于
$('input[type=checkbox]').click(function()
{
var row = $(this).parent(); //this or something like it, you want the TR element, it's just a matter of how far up you need to go
var columns = row.children(); //these are the td elements
var id = columns[0].val(); //since these are TDs, you may need to go down another element to get to the actual value
if (!this.checked) //becomes checked (not sure may be the other way around, don't remember when this event will get fired)
{
var val1 = columns[1].val();
var val2 = columns[2].val();
myCheckValues[id] =[val1,val2]; //Add the data to your global object which should be declared on document ready
}
else delete myCheckValues[id];
});
提交时,从您的对象中获取选定的行:
for (var i = 0; i < myCheckValues.length; i++)
...
抱歉,很长时间没有做 JS 了,所以按原样编写代码可能行不通,但你明白了。