hi
hello friends, i have problem here, please help me.
i have a jsp page in that jsp page i am displaying the data retrived from the database(mysql). i am displaying data in table format.
noe the problem is i want to color table cell based on cell value. that is if table cell consists value say "met" then i want to color that table cell in green color. like this for other cell.
first i want check the value and then select bgcolor for that cell accordingl .
i need working code for this . or sample code for checking condition in <td> tag.
this is the code i am using to display the data in html form
<table border="1" cellpadding="1" cellspacing="2">
<tr bgcolor=
"lightblue">
<th>Type
</th>
<th WIDTH=
40>IdNUM
</th>
<th>ProdNum
</th>
<th>SolID
</th>
<th WIDTH=
%200>Title
</th>
<th>DevManager
</th>
<th>Owner
</th>
<th>Severity
</th>
<th>Status
</th>
<th>Analysis Due
</th>
<th>Agoal
</th>
<th>Pgoal
</th>
<th>Igoal
</th>
<th>Fgoal
</th>
</tr>
<%
Class.forName(
"sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection(
"jdbc:odbc:mmt",
"root",
"admin");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(
"select Type,idnum,ProdNum,SolID,Title,DevManager,Owner,Severity,Status,AnalysisDue,Agoal,Pgoal,Igoal,Fgoal from wmr where ( SolInDev > 5 AND AnalysisDone=' ' ) AND (IsExternal='y')");
try {
String bgColor =
"silver";
while (rs.next()) {bgColor = bgColor.equals("silver") ? "white" : "silver";%>
<tr bgcolor=
"<%=bgColor
%>">
<td align=
"center"><%= rs.getString(
"Type")
%></td>
<td ><%= rs.getString(
"Idnum")
%></td>
<td align=
"right" ><%= rs.getString(
"ProdNum")
%></td>
<td align=
"right" ><%= rs.getString(
"SolId")
%></td>
<td align=
"center"><%= rs.getString(
"Title")
%></td>
<td align=
"center"><%= rs.getString(
"DevManager")
%></td>
<td align=
"center"><%= rs.getString(
"Owner")
%></td>
<td align=
"center"><%= rs.getString(
"Severity")
%></td>
<td align=
"center"><%= rs.getString(
"status")
%></td>
<td align=
"center"><%= rs.getString(
"AnalysisDue")
%></td>
<td align=
"center"><%= rs.getString(
"Agoal")
%></td>
<td align=
"center"><%= rs.getString(
"Pgoal")
%></td>
<td align=
"center"><%= rs.getString(
"Igoal")
%></td>
<td align=
"center"><%= rs.getString(
"Fgoal")
%></td>
</tr>
<% }
rs.close();
conn.close();
}
catch (Exception e) {
out.println(
"Exception: " + e.getMessage());
}
%>
</table>
</body>
</html>
if pgoal value = "met" then change that cell color to green. i want this.
i think now u can provide me some code
thanks and regards
manjunath