I have a SQL query in a web application, what I want to show is that the rows of with total = 100
are shown in color verde
and the rows with total = 0
are shown in color rojo
, but I don't know how to implement this function.
Could you help me?
<%
consulta conexion = new consulta ("jdbc:oracle:thin:@localhost:1521:XE","pasaportes","oppasaportes");
String consulta = "SELECT id_delegacion, CONTRATO , prerequisitos_tecnologicos, equipamiento, sistema_operacion, privilegios, capacitacion, citas FROM delegaciones";
ResultSet rs = conexion.ejeSelect(consulta);
ResultSetMetaData rsmd = rs.getMetaData();
int col= rsmd.getColumnCount();
for(int k=1;k<=col;k++){
%>
<td><h9> <%= rsmd.getColumnName(k) %></h9></td>
<%
}
%>
</tr>
<%
while(rs.next()){
%>
<tr class="info">
<td><h6><%= rs.getString(1) %></h6> </td>
<td><h6><%= rs.getString(2) %></h6> </td>
<td><h6><%= rs.getString(3) %></h6> </td>
<td><h6><%= rs.getString(4) %></h6> </td>
<td><h6><%= rs.getString(5) %></h6> </td>
<td><h6><%= rs.getString(6) %></h6> </td>
<td><h6><%= rs.getString(7) %></h6> </td>
<td><h6><%= rs.getString(8) %></h6> </td>
</tr>
<%
}
%>
</table>
</div>
As you have said that it is a dynamic table, in the program with which you fill your table you put a condition in which you give a class name or an id to the row when the value is = 100 and another when = 0 and then by CSS you give it the color you want.
I leave you an example in which the color of the entire row is changed. When the value is zero, the tr element would be like this:
<tr id="cero">...</tr>
and if it is one hundred it would be<tr id="cien">...</tr>
, then, by CSS, the color of the entire row is changed simply with this:.info tr#cero { color:red; }
, if you only want to change the color of one column, it would be with this:.info td#cero { color:red; }
and in that case would assign the id="zero" or id="hundred" not to the whole row, but to the specific column you want to change.You can use javascript to go through the table and assign a color to it. I'll give you an example that you have to adjust a bit to your table.
You can also use jQUERY for color and bold validation