Jump to content
Larry Ullman's Book Forums
banacan

Another Question About Recursive Function

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...