Good morning,
I am having trouble with the following code
<html>
<head>
<title>highlight date</title>
<style>
.row {
background-color: Yellow;
color:blue;
}
</style>
<script type="text/javascript">
</script>
<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<script language="javascript">
var currentTime = new Date();
var day = currentTime.getDate();
var month = currentTime.getMonth() + 1;
var year = currentTime.getFullYear();
var review = day + "/" + month + "/" + year;
</script>
<script language="javascript">
$(document).ready(function() {
$('#names td:contains(xxxx)').parent().addClass('row');
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table id="names">
<tbody>
<tr>
<td>1</td>
<td>review</td>
</tr>
<tr>
<td>2</td>
<td>Satheesh</td>
</tr>
<tr>
<td>3</td>
<td>08/10/2010</td>
</tr>
<tr>
<td>4</td>
<td>11/10/2010</td>
</tr>
<tr>
<td>5</td>
<td>xyz</td>
</tr>
</tbody>
</table>
</div>
</form>
<h4>It was
<script type="text/javascript">document.write(review)</script></h4>
</body>
</html>
I get get it to highlight a set string, but for some reason when ever i try to declare the variable “review” as what i want to search for and highlight, all it seems to find is the word review. can anyone help me on this at all please? its starting to do my head in.
Thankyou
I’m guessing you’re trying
you should instead concatenate your variable:
which will join
'#names td:contains('to the value of your variable, followed by')'EDIT: I took pity. Below is my solution to the additional question you asked in the comments. Please note you should make the parseDate function more robust.
This gets each row and iterates through them. It gets the textual value of the SECOND (0-index) td, and parses it to a date. If this date is less than today, it applies the class.
It DOES NOT check whether the data is an actual date or not, so you should add in that check somehow.