GTR Mora GTR Mora - 1 year ago 46
HTML Question

How to take the Dynamic-table cell value in java

This is a table of one of my jsp page. I want to take the selected value of the column empId for a javascript method.

<table class="table table-bordered">
<th>Employee ID</th>
<th>Employee Name</th>
<th>Casual Leave Balance</th>
<th>Annual Leave Balance</th>
<th>Sick Leave Balance</th>
<c:forEach var="leavebalances" items="${LeaveAllBalanceList}">
<td><dev class="correct" name="empId" onclick="selectempId(this)"> ${leavebalances.empId}</dev></td>

my javascript code segment

function selectempId(emp){

But It (onclick) doesn't work. There are only methods to get selected values of dynamic dropdowns. Please tell me how to do this.
Thank you.

Answer Source

You can pass value to javascript. But I don't know the dev tag in html. I think it is div.

<td><div class="correct" name="empId" onclick="selectempId(${leavebalances.empId})"> ${leavebalances.empId}</div></td>

Or you can pass to td's onclick action.

<td onclick="selectempId(${leavebalances.empId})">${leavebalances.empId}</td>