Reputation: 34523
function highlightRow(searchRow)
{
if(searchRow != null)
{
var oRows = document.getElementById('Table').getElementsByTagName('tr');
//use row number to highlight the correct HTML row.
var lastTwo = searchRow;
lastTwo = lastTwo.slice(-2); //extract last two digits
oRows[lastTwo].style.background="#90EE90";
}
}
I got paging off 100 rows.
When searchRow returns 55, I highlight row 55.
When searchRow returns 177, I highlight row 77, hence the slice function.
Now the issue:
When searchRow returns 03 or 201, the indexing on oRows[] does not work.
Why is this?
To confuse me more when I hard coding "03" it does work:
oRows[03].style.background="#90EE90";
Any insight into how this works?
Does jQuery have this issue?
Thank you.
Upvotes: 0
Views: 70
Reputation: 630389
You're dealing with a string currently, you need an integer here, like this:
oRows[parseInt(lastTwo, 10)].style.background = "#90EE90";
To do an accurate test to see it in action you'll see this works:
oRows[03].style.background="#90EE90";
But this (what's actually happening now) doesn't:
oRows["03"].style.background="#90EE90";
Upvotes: 2