Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlighting rows

Status
Not open for further replies.
Heres my code:

// for every table row ...
var rows = document.getElementsByTagName('tr');
for ( var i = 0; i < rows.length; i++ ) {

if ( 'hgh' == rows.className.substr(0,3)) {
// ... and to mark the row on click ...
rows.onmousedown = function() {
var unique_id;
if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
marked_row[unique_id] = true;
} else {
marked_row[unique_id] = false;
}

if ( marked_row[unique_id] ) {
this.className += ' marked';
} else {
this.className = this.className.replace(' marked', '');
}
}
};

}; //for every row



On this page:

The white table with the grey header, middle bottom of page, does not highlight correctly.
Will highlight on the first click but then after that sometimes it unhighlights, sometimes not. Sometimes it takes more than one click to highlight or restore.

Any ideas?
 
Here it is in its simplest form:

Heres the problem...
I want to be able to highlight multiple rows.

Do this:
- click any row
- click it again, it will UNhighlight. That works fine.

- now try to highlight and UNhighlight multiple rows.

Doesnt always work.

Why?

I think it has to do with the unique_id variable that is set to true or false.

Can anyone figure it out?

No responses as of yet...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top