views:

511

answers:

1

I have a table which the rows are loaded dynamically from a recordset. I also have used Javascript so that when a checkbox (not in the table) is checked it hides all the rows when column x = y, but I have a vertical border (really just a background image positioned to the right)which fades on the last row of the table using the CSS .sortable .dynamicrow:last-child td{

So when I check the box and the last one row is removed, the border doesn't fade properly basically I need to rerun/refresh the CSS.

In all I am asking how to refresh the style/CSS of an element in javascript.

   .sortable .dynamicrow:last-child td{
    background-image:url(../Images/tablevborderbottom.png);
    background-position:right;
    background-repeat:no-repeat;
}

Is the CSS I use to have the vertical border fade on the last row Sometimes the last row gets removed, so the second last row becomes the last row, but it keeps it's solid border and it doesn't fade out.

Another way of putting it is, after the page has loaded, because of Javascript sometimes the last-child gets removed, so child above it becomes the last-child, how do I apply the above CSS to the new last-child?

A: 
Psytronic
Will it matter if the number of rows is dynamic? So there is no set number?
Jonathan
Nope, it won't matter, it will work with as many rows as there are in the sorttable. However you will need to tweak it to work with the fact that this is based on clicking an element within the table, however you've got one checkbox which exists outside the table. If you are not able to work out how to change it let us know.
Psytronic
Could you explain each line of code I kind of get the idea but I'd like to fully understand it. I understand setting the variables.
Jonathan
Sure, bascially working on the principle that the row arg is a button within a TD element, going parentNOde.parentNode will take us to the table row containing the button pressed (button -> td -> tr). We then get all the table rows of the sorttable, next we check if the button pressed is the last row of the table, or the last visible row (as the last visible row has the dummy_last_row class) if it is loop through all the rows, and if the current row loop is the row of the input pressed, and that there is a row before that row (so that not all the rows get hidden) apply the dummy class
Psytronic
You'll also need to remove that class on hiding a row, and deal with other things like that, but I'm sure you can do that :)
Psytronic