?
Solved

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

Posted on 2006-10-30
7
Medium Priority
?
495 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
Independent Software Vendors: 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!

 
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 1000 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

743 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