Hello sorry for my english, I'm new to freemarker and Js. How can i make each row in #list clickable by id. So when its clicked it will send me to edit form for that id:
function addRowHandlers() {
var table = document.getElementById(show);
var rows = table.getElementsByTagName("tr");
for (i = 0; i < rows.length; i++) {
var currentRow = table.rows[i];
var createClickHandler = function(row) {
return function() {
var cell = row.getElementsByTagName("td")[0];
var id = cell.innerHTML;
alert("id:" + id);
};
};
currentRow.onclick = createClickHandler(currentRow);
}
}
This is my ftl list template:
<table border="1" id="tableId">
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr>
<#list users as show>
<tr>
<td>${show.firstName!""}</td>
<td>${show.lastName!""}</td>
</tr>
</#list>
I expect to click the row in my form and it will send me to edit page according on each id. But I cannot assign the id for each row Thanks!