Solved

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

Posted on 2006-10-30
7
488 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

810 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