aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Removing row from table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Removing row from table" Watch "Removing row from table" New topic
Author

Removing row from table

Sowmiya Selvamani
Greenhorn

Joined: Oct 29, 2007
Posts: 6
First i am changing the background color of a row in a table on mouse click. Then If I press remove button i need to remove all the rows which has background color. can anyone help me to do this?
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
I believe in jQuery it would look something like...



Check into it. Its very nice

www.jquery.com

thanks
Bryce
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Loop through all of the table rows and remove the class.

var rows = document.getElementById("yorTableId").getElementsByTagName("tr");
for(var i=0;i<rows.length;i++){
rows[i].style.className = "normal";
}

Eric
[ January 21, 2008: Message edited by: Eric Pascarello ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60074
    
  65

Small correction to jQuery example:


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
My first idea was to code it as you have coded it. I use Visual jQuery 1.1 to look at the methods and how they are used. http://visualjquery.com/1.1.2.html

Now, I know that 1.2.2 is out but this should still apply. If you look under DOM -> Manipulation -> remove the example seems to show the way I coded it. Is it wrong on there? Is there a better quick reference out there than that site?

Thanks Bryce
Yehuda Katz
Author
Greenhorn

Joined: Jan 14, 2008
Posts: 21
What Bear said'll work great! Keep in mind, however, that animating table changes is still quite a bit of black magic, because table rows can't smoothly and reliably change size. If you want to change the size of a table row, you'll probably need to wrap all of the TRs in individual DIVs, give the DIVs overflow: hidden, and then shrink the divs.

something like

where you have the following in your CSS:

[ January 21, 2008: Message edited by: Yehuda Katz ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60074
    
  65

Yeah, I should have said "alternative" rather than correction. My bad. There's no need to select all the tr's and then filter them rather than selecting only the target ones in the first place.
[ January 21, 2008: Message edited by: Bear Bibeault ]
Yehuda Katz
Author
Greenhorn

Joined: Jan 14, 2008
Posts: 21
My comment above, just to be clear, only applies to *animating* table cells with slideUp or slideDown. That's because table cells can't get overflow: hidden and so can't animate smoothly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Removing row from table
 
Similar Threads
Hiding text in JTable
JTable color problem
xml data islands + alternate row color
Flashing a row in Jtable
table row selected issue