?
Solved

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

Posted on 2006-10-30
7
Medium Priority
?
508 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
6 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
Technology Partners: 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

755 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