2016-01-14 100 views
-1

我是java web techology中的新成员。图像显示输出表。如果我点击分配按钮,则会调用一个ajax请求,如果同一行的第二列出现这个请求,这个请求将会取得数据。我能做什么? TIA :) data table如何在ajax请求中发送表格行数据

+0

看一看jQuery的关于如何访问td文本。如果你在'Assing'上有一个事件处理函数,那么它就像$(this).closest('tr')。find('td:nth-​​child(3)' –

回答

0

纯JS功能可能是(一步一步)

function getDataTable(theButton){ 
    ... 
    var theTD = theButton.parentNode; 
    var theTR = theTD.parentNode; 
    var brothers = theTR.childNodes; /* Including the button's td.*/ 
    /* Select a cell, counting from 1 to N.*/ 
    brothers[/*the td-index you want*/].innerHTML = /* the value you want to set.*/ 
    brothers[/*the td-index you want*/].innerHTML; /* or simply get the value it already have.*/ 
    ... 
    /*your AJAX code*/ 
} 

您的按钮应该是这个样子:

<button onclick="getDataTable(this);">Get data</button>