I have an *.jsp file.
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<title>
Drop Down List in Table Cell Depending on Name of Table Column
</title>
</head>
<body>
<table id="Sample Table" border="1">
<tr>
<c:forEach var="element" items="${requestScope.tableColumnNames}">
<th>${element}</th>
</c:forEach>
</tr>
<c:forEach var="elements" items="${requestScope.tableRowValues}">
<tr>
<c:forEach var="element" items="${elements}">
<td>${element}</td>
</c:forEach>
</tr>
</c:forEach>
</table>
</body>
</html>
The parameter tableColumnNames is an array:
String[] tableColumnNames = new String[]{“Table Column One”,”Table Column Two”};
The parameter tableRowValues is an array:
String[][] tableRowValues = new String[][]{{“Sample Value”, “Yes / No”}};
I would like to have just for column two with the column name ‘Table Column Two’ the data displayed in a DropDown.
My assumption is to get from each cell the reference to the column and then use a if condition:
<c:forEach var="element" items="${elements}">
<td>${element}
<c:if <reference from cell to column (name)>="Table Column Two">
<select>
<option value="optionYes">
Yes
</option>
<option value="OptionNo">
No
</option>
</select>
</c:if>
</td>
</c:forEach>
I am not sure if this approach is correct.
Please adivse. Thanks much for your help.