I am having a table which is made based on data fetching from database.Now i want to change the color of rows depending on weather the readstatus of that row in database is "YES" or "NO". So my code to do it is as follow :
<% while(rs.next())
{
String messageid=rs.getString("MESSAGE_ID");
String sendername=rs.getString("EMAIL_FROM");
String messagesubject=rs.getString("EMAIL_SUBJECT");
Timestamp sendingtime=rs.getTimestamp("EMAIL_TIME");
String readstatus=rs.getString("READSTATUS");
if(readstatus.compareTo("NO")==0)%>
<tr bgcolor="66FF00"> </tr>
<%
if(readstatus.compareTo("YES")==0)
%>
<tr bgcolor="660000"> </tr>
<tr onmouseover="ChangeColor(this, true);" onmouseout="ChangeColor(this, false);" onclick="DoNav('showmail.jsp?mid=<%=messageid%>');">
<td callspan="3"><%=sendername%> : <%=messagesubject%> <%=sendingtime%></td>
</tr>
<tr/>
<%
} %>
</tr>
But the color of all the rows is still shown same.Whats wrong in this code?
Secondly , i want the sending time to be shown atmost right side and sendername at nost left and messagesubject in middle of my row in table.How to do that ?
There are several stylistic problems with this code, but I'll pass over those. To get it functional will just require realizing that HTML hex colors need a #: #66FF00
not 66FF00
.
And on the sendingtime issue, just make it 3 tds insted of one td with colspan='3'. (You also spelled colspan wrong. Its col as in column, not call.)
I am having a table which is made based on data fetching from database.Now i want to change the color of rows depending on weather the readstatus of that row in database is "YES" or "NO". So my code to do it is as follow :
<% while(rs.next())
{
String messageid=rs.getString("MESSAGE_ID");
String sendername=rs.getString("EMAIL_FROM");
String messagesubject=rs.getString("EMAIL_SUBJECT");
Timestamp sendingtime=rs.getTimestamp("EMAIL_TIME");
String readstatus=rs.getString("READSTATUS");
if(readstatus.compareTo("NO")==0)%>
<tr bgcolor="66FF00"> </tr>
<%
if(readstatus.compareTo("YES")==0)
%>
<tr bgcolor="660000"> </tr>
<tr onmouseover="ChangeColor(this, true);" onmouseout="ChangeColor(this, false);" onclick="DoNav('showmail.jsp?mid=<%=messageid%>');">
<td callspan="3"><%=sendername%> : <%=messagesubject%> <%=sendingtime%></td>
</tr>
<tr/>
<%
} %>
</tr>
But the color of all the rows is still shown same.Whats wrong in this code?
Secondly , i want the sending time to be shown atmost right side and sendername at nost left and messagesubject in middle of my row in table.How to do that ?
There are several stylistic problems with this code, but I'll pass over those. To get it functional will just require realizing that HTML hex colors need a #: #66FF00
not 66FF00
.
And on the sendingtime issue, just make it 3 tds insted of one td with colspan='3'. (You also spelled colspan wrong. Its col as in column, not call.)
0 commentaires:
Enregistrer un commentaire