banacan Posted January 23, 2013 Share Posted January 23, 2013 I am using a modification of Script 1.3 to display a list, but the list is being displayed in a table, not a nested ul. Because I want to indicate the hierarchical relationship, I need to add left padding to all child items. So what I've done is add an incrementing number ("T1", "T2", etc.) as a class for each <tr> that has children. That works great and I can increase the left padding based on the "T" number. The problem is that the last child doesn't get the "T" number because it has no children itself. Can anyone suggest a method for targeting the last child in the hierachy? Many thanks. Link to comment Share on other sites More sharing options...
HartleySan Posted January 23, 2013 Share Posted January 23, 2013 This article is about MySQL recursion, but I think it'll give you some interesting ideas: http://www.sitepoint.com/hierarchical-data-database-2/ Link to comment Share on other sites More sharing options...
banacan Posted January 23, 2013 Author Share Posted January 23, 2013 Hi HartleySan, Yes, I read that article before when you mentioned it in a reply in another thread. It is very interesting. However since I am so close already, and since I already have the styling set in my CSS, I'm hoping someone can suggest a way of targeting the last child. Thanks for your reply. Link to comment Share on other sites More sharing options...
HartleySan Posted January 23, 2013 Share Posted January 23, 2013 Oh, sorry. I didn't realize that I had recommended that same page to you before. Anyway, why is it not possible to style the bottom-level elements in the same way that you're styling the other elements? When you call the recursive function, aren't you sending some sort of incrementing number as an argument to handle the class assignment? Link to comment Share on other sites More sharing options...
banacan Posted January 24, 2013 Author Share Posted January 24, 2013 Thanks again for replying. No, you didn't recommend that article to me but someone else. I just happened to read the thread and I was intrigued. Well, silly me. Sometimes I make things more complicated than they really are. While driving to the store I realized what logic I needed to determine the last child: items that are not top-level items (pid != 1) and have no dependents. Too easy. Link to comment Share on other sites More sharing options...
Recommended Posts