Announcement

Collapse
No announcement yet.

section quantity in section name

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    section quantity in section name

    Hi, i am trying to get the number of child sections to display on a section name....i am using the javascript yahoo menu....and on my subsections i want to display how many sections are inside it like section name (3)

    i tried using this method

    ar[i].pChild.length

    which works and shows how many section are in the current section but i need how many are in the third subsection...the ones which arent generated in the script......so basically i need something like

    ar[i].pChild.pChild.length

    but this doesnt work....im sure norman would know if he is around

    help woulod be greatly appreciated

    #2
    On holiday in the Canaries (if Jo's listening - in Corralejo - with big waves), with only limited resources.

    Suggest you look at the YahooSections code and make a new inner loop based on the second-level one.

    UPDATE. Something like this (YahooSections expanded to 3 levels) - you'll have to add in the count display yourself:
    Code:
    function YahooSections(ar)
    {
    var strIDs = '';
    for (var i=1;i<=ar.length;i++)
      {
      if (ar[i].sURL != null)
        {
        strIDs += '<a href="' + directURL(ar[i].sURL) + '"><span class="actxxsmall"><font color="NETQUOTEVAR:FGCOLORCSS">' + ar[i].sName + '</font></span></a><br>';
          {
          if (ar[i].pChild)
            {
            for (var j=1;j<=ar[i].pChild.length;j++)
              {
              if (ar[i].pChild[j].sURL != null)
                {
                strIDs += '--<a href="' + directURL(ar[i].pChild[j].sURL) + '"><span class="actxxsmall"><font color="NETQUOTEVAR:FGCOLORCSS">' + ar[i].pChild[j].sName + '</font></span></a><br>';
    	    if (ar[i].pChild[j].pChild)
                  {
                  for (var k=1;k<=ar[i].pChild[j].pChild.length;k++)
                    {
                    strIDs += '----<a href="' + directURL(ar[i].pChild[j].pChild[k].sURL) + '"><span class="actxxsmall"><font color="NETQUOTEVAR:FGCOLORCSS">' + ar[i].pChild[j].pChild[k].sName + '</font></span></a><br>';
                    }
                  }
                }
              }
            }
          }
        strIDs += '<br>'
        }
      }
    return strIDs
    }
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Thanks Norman....although i dont actually need the third section displaying...i just need to know how many sections there are.

      the problem is im using a slashdot style drop menu...so i've customised it slightly........basically i need var [j] and var[k] to be displayed together but if i put it in the order you shoed var[k] is declared after the second section so im not sure how i get k into the second menu.....heres my current script.

      HTML Code:
      <script type="text/javascript" src="sdmenu.js">
      		/***********************************************
      		* Slashdot Menu script- By DimX
      		* Submitted to Dynamic Drive DHTML code library: [url]http://www.dynamicdrive.com[/url]
      		* Visit Dynamic Drive at [url]http://www.dynamicdrive.com/[/url] for full source code
      		***********************************************/
      	</script>
          <script type="text/javascript">
      	// <![CDATA[
      	var myMenu;
      	window.onload = function() {
      		myMenu = new SDMenu("my_menu");
      		myMenu.init();
      	};
      	// ]]>
      	</script>
      <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
      <!--
      function YahooSections(ar)
      {
      var strIDs = '';
      for (var i=1;i<=ar.length;i++)
        {
        if (ar[i].sURL != null)
          {
      	strIDs += '<div class="collapsed">';
      	strIDs += '<span><a href="#" class="top_section">' + ar[i].sName + '</a></span>';
            {
            if (ar[i].pChild)
              {
              for (var j=1;j<=ar[i].pChild.length;j++)
                {
                if (ar[i].pChild[j].sURL != null)
                  {
                  strIDs += '<a href="' + ar[i].pChild[j].sURL + '" class="sub_section">' + ar[i].pChild[j].sName +'</a>';
      if (j==ar[i].pChild.length)
      {strIDs += '</div>';
      }
      
      if (ar[i].pChild[j].pChild)
                    {
                    for (var k=1;k<=ar[i].pChild[j].pChild.length;k++)
                      {
                      strIDs += ''+ ar[i].pChild[j].pChild[k].sName + '';
                      }
                    }
                  }
                }
              }
            }
          strIDs += ''
          }
        }
      return strIDs
      }
      </SCRIPT>
      ive currently got the third section dumped at the bottom...it displays but i need to know how to get the number of sections from [k] into what is displayed by [j]

      hope that makes sense......dont worry if you busy to look further at this.....i'd probably figure it eventually....would just take me ages of trial and error

      Comment


        #4
        Sorry. I won't be able to look at this.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment

        Working...
        X