How to replace rows of a html table using javascript

Last week , i had some troubles when I was trying to replace the html rows.The issue that I encountered is , whenever you switch rows using innerHTML property , controls loose their values/

So what I find out using googling , is to use the insertBefore function of the DOM

To achieve the function of replacing the upper or lower rows of the table ;

row = GetRowReferenceBySomeHow();

tbody = GetBodyReference();// or you can simple use row.parentNode 

isUp = true ; // whatever you choose(true is cool always , we dont like false(s)!

 

if(isUp) 

 tbody.insertBefore( row.previousSibling,row);

else

   tbody.insertBefore( row, row.nextSibling );

 

Viole! Cool huh ? Actually , nothing is cool , but since we are geek ( or at least I am (not always ) ) !

 

 

 

posted @ Sunday, May 25, 2008 3:38 PM

Print

Comments on this entry:

# re: How to replace rows of a html table using javascript

Left by Paulo at 5/29/2008 7:44 PM
Gravatar
Nested parenthesis in text!
Very Geeky!!! :D

Your comment:



 (will not be displayed)


 
 
 
Please add 1 and 4 and type the answer here:
 

Live Comment Preview:

 

Enter your email address:

Delivered by FeedBurner

«January»
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567