這是我的一個jsp頁面的表格。我想爲javascript方法採用empId列的選定值。如何在JavaScript中使用Dynamic-table單元格值
<table class="table table-bordered">
<thead>
<tr>
<th>Employee ID</th>
<th>Employee Name</th>
<th>Casual Leave Balance</th>
<th>Annual Leave Balance</th>
<th>Sick Leave Balance</th>
</tr>
</thead>
<tbody>
<c:forEach var="leavebalances" items="${LeaveAllBalanceList}">
<tr>
<td><dev class="correct" name="empId" onclick="selectempId(this)"> ${leavebalances.empId}</dev></td>
<td>${leavebalances.empId}</td>
<td>${leavebalances.casual}</td>
<td>${leavebalances.annual}</td>
<td>${leavebalances.sick}</td>
</tr>
</c:forEach>
</tbody>
</table>
我的javascript代碼段
function selectempId(emp){
alert(emp);
}
但它(的onclick)不起作用。只有方法才能獲取動態下拉列表的選定值。請告訴我如何做到這一點。 謝謝。
'onclick()=「selectempId(this)」'什麼是'()'?這是正確的嗎? – epascarello
@epascarello no no,它應該更正爲onclick =「selectempId(this)」。謝謝。 –