Help: Need to disable a table row based on the content of one of its cells

sk3pt1c

macrumors 6502a
Original poster
Nov 29, 2005
913
4
a simulacrum
So there's a table being created by PHP of user records, some users are deleted but still show up on the table as deleted and i want to make that row disappear where there is a td that contains the text "deleted".
i get that this can't be done with CSS cause i don't want to target an attribute but perhaps with javascript?
so basically i want to get the element that is a table -> td that contains the string "deleted" and set a "display:none" to its parent row.
Help? :)
Thanks
 

bpaluzzi

macrumors 6502a
Sep 2, 2010
919
1
London
So there's a table being created by PHP of user records, some users are deleted but still show up on the table as deleted and i want to make that row disappear where there is a td that contains the text "deleted".
i get that this can't be done with CSS cause i don't want to target an attribute but perhaps with javascript?
so basically i want to get the element that is a table -> td that contains the string "deleted" and set a "display:none" to its parent row.
Help? :)
Thanks
Why not set a class of "deleted" on that row?
 

sk3pt1c

macrumors 6502a
Original poster
Nov 29, 2005
913
4
a simulacrum
I can't mess with the table at its creation and it's not certain which rows will be rows with a "deleted" user on them.
I need a way to target said row with javascript so i can set it to not display at all or at least change its styling to color it a different color so it's more evident that it's about a deleted user
 

bpaluzzi

macrumors 6502a
Sep 2, 2010
919
1
London
Are the users being deleted after the page is drawn?

Attach a jQuery call to $(this).parents('tr').addClass('deleted') on your ajax binding. Have the styling in CSS, as normal.
 

sk3pt1c

macrumors 6502a
Original poster
Nov 29, 2005
913
4
a simulacrum
I'm kind of a noob at this, bear with me please
The table data will be pulled from a database, one of the fields in there is whether the user is deleted or not, so it will fill one td at the end of each tr with the user state.
What i need to do is find the rows that contain users that are deleted, ie look for a td that contains the word "deleted", and apply some css to it, either by giving it a class name and have the rule for it ready in my css, or by adding the styling via the javascript as a span or something.
Where would i add the call you suggested in that case?
Sorry if i'm not making sense :)
 

bpaluzzi

macrumors 6502a
Sep 2, 2010
919
1
London
I'm kind of a noob at this, bear with me please
The table data will be pulled from a database, one of the fields in there is whether the user is deleted or not, so it will fill one td at the end of each tr with the user state.
What i need to do is find the rows that contain users that are deleted, ie look for a td that contains the word "deleted", and apply some css to it, either by giving it a class name and have the rule for it ready in my css, or by adding the styling via the javascript as a span or something.
Where would i add the call you suggested in that case?
Sorry if i'm not making sense :)
No worries -- I'm not quite sure I understand what you're trying to do here, to be honest :)

If the user status (deleted vs active) is known at page-draw time (i.e., you're not waiting on any user input to set them deleted), I'd go back to setting a class on the tr via php. Are you using any templating language, or just outputting raw HTML via PHP?
 

sk3pt1c

macrumors 6502a
Original poster
Nov 29, 2005
913
4
a simulacrum
I think it's the latter.
There's no user input, it's just outputting the database table data.
How would i add the class in the php though?
I'd still need to find the rows that have "deleted" in them, no?
I guess i'd rather not mess with the php cause it might affect other files that do the same thing, it's part of a cms...
 

elppa

macrumors 68040
Nov 26, 2003
3,229
106
Do have access to jQuery?

If so, you can use contains:
http://api.jquery.com/contains-selector/

Code:
$("td:contains(delete)").closest("tr").hide();
Of course, you have to be careful that the other cells won't also contain delete!

Same principle, run in the webkit console on this page:

Code:
$("a.bigusername:contains(sk3pt1c)").closest("div.page").fadeOut()