Solved

Change table row <TR></TR> colour in php page?

Posted on 2006-10-30
7
493 Views
Last Modified: 2008-02-01
Experts,

I have a php page, with the following style specified within the head section;

<style type="text/css">
td.clickable { background: orange; color: red; cursor: pointer; }
</style>

Within the page I output some data from my database, with the following;

echo "<TR onclick=\"location.href='somelink.htm';\" onmouseover=\"this.className='clickable';\" onmouseout=\"this.className='';\">\n";

echo "<TD><a href='viewasset.php?varl=".$row['ID']."' class=\"blue5\">".$row['ID']."</a></font></TD><TD>".$row['CSName']."</TD><TD>".$row['SystemOrganization']."</TD><TD>".$row['LastAudit']."</TD><TD>".$row['LastAudit']."</TD></TD>\n";

echo "</TR>\n";

I would like to change the row colour, and use the row itself as a link?  This is currently not working.
0
Comment
Question by:nickmarshall
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 58

Expert Comment

by:amit_g
ID: 17834403
Change the style to

<style type="text/css">
tr.clickable { background: orange; color: red; cursor: pointer; }
</style>

0
 
LVL 1

Author Comment

by:nickmarshall
ID: 17834831
Hi,

I have done what you have suggested however the table row does not change colour when the mouse hovers.
0
 
LVL 58

Expert Comment

by:amit_g
ID: 17835055
In the browser do view source and post what you get.
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
LVL 1

Author Comment

by:nickmarshall
ID: 17835270
Here is the source...

<tr style="background-color:#ffffff;" onMouseOver="this.className='highlight'" onMouseOut="this.className='normal'">
<TD><a href='viewasset.php?varl=000476150ACD' class="blue5">000476150ACD</a></font></TD><TD>GIACOM-SUPPORT</TD><TD>2006-10-30</TD><TD>2006-10-30</TD><TD>2006-10-30</TD>
</TR>
0
 
LVL 58

Expert Comment

by:amit_g
ID: 17835506
this.className='highlight'
should be
this.className='clickable'

Check your code as the code you posted would put clickable in it but the view-source is showing highlight. If not sure change the style to

<style type="text/css">
tr.clickable { background: orange; color: red; cursor: pointer; }
tr.highlight { background: orange; color: red; cursor: pointer; }
</style>
0
 
LVL 6

Accepted Solution

by:
davbouchard earned 250 total points
ID: 17835739
I've tried it with just code and it works.

<html>
<head>
<style>
tr.clickable {background: orange; color: red; cursor: pointer}
tr.normal {background: white; color: black; cursor: default}
</style>
</head>

<body>
<table>
<tr onclick="location.href='http://www.google.com';" onMouseOver="this.className = 'clickable'" onmouseout="this.className = 'normal'">
      <td>Test</td><td>Test2</td>
</tr>
</table>
</body>
</html>
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to count occurrences of each item in an array.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question