Solved

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

Posted on 2006-10-30
7
473 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now