Array.length not correct when using TableRowObjects?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • F Da Costa

    Array.length not correct when using TableRowObjects?

    Hi,

    Small question re the use of an Array.
    I'v got an array with x rowObjects in it.
    When i get it the type of the container is Array and i can get a hold of
    the objects just fine.

    owever, how do i get the length of the array?
    For container.lengt h does not seem to work.

    TIA
    Fermin DCG

    dacostagomez at gmail.com
  • Ivo

    #2
    Re: Array.length not correct when using TableRowObjects ?

    "F Da Costa" wrote[color=blue]
    > Small question re the use of an Array.
    > I'v got an array with x rowObjects in it.
    > When i get it the type of the container is Array and i can get a hold of
    > the objects just fine.
    >
    > owever, how do i get the length of the array?
    > For container.lengt h does not seem to work.[/color]

    You have misspelled the word length as lenght. Happens all the time.
    Or provide some clues by showing us some code.
    HTH
    Ivo


    Comment

    • F Da Costa

      #3
      Re: Array.length not correct when using TableRowObjects ?

      Ivo wrote:[color=blue]
      > "F Da Costa" wrote
      >[color=green]
      >>Small question re the use of an Array.
      >>I'v got an array with x rowObjects in it.
      >>When i get it the type of the container is Array and i can get a hold of
      >>the objects just fine.
      >>
      >>owever, how do i get the length of the array?
      >>For container.lengt h does not seem to work.[/color]
      >
      >
      > You have misspelled the word length as lenght. Happens all the time.
      > Or provide some clues by showing us some code.[/color]

      Point wel taken. Unfortunately there was no typo.
      To make matters worse. When using the Venkman debugger the content of
      the object (of type Array) showed the two HtmlRowTableEle ments just fine
      and the parameter length said 0.

      Following the code:
      ....
      var ch = getChildSegment s(segment, 1);
      if (ch.length>0)
      displayDirectCh ildren(ch, onOff);
      ....

      ch is filled correctly as verified in the debugger, breakpoint on the if
      line.
      The displayDirectCh ildren function is correct because this line is the
      last one in that particular function (recursive call).

      TIA
      Fermin DCG

      Comment

      • Richard Cornford

        #4
        Re: Array.length not correct when using TableRowObjects ?

        F Da Costa wrote:[color=blue]
        > Ivo wrote:[/color]
        <snip>[color=blue][color=green]
        >> Or provide some clues by showing us some code.[/color][/color]
        <snip>[color=blue]
        > Following the code:
        > ...
        > var ch = getChildSegment s(segment, 1);
        > if (ch.length>0)
        > displayDirectCh ildren(ch, onOff);
        > ...[/color]
        <snip>

        No array is created of filed in this code. The contents of the -
        getChildSegment s - function would be more relevant, along with the
        context in which it is called (i.e. what does - segment - refer to?).

        Richard.


        Comment

        • Grant Wagner

          #5
          Re: Array.length not correct when using TableRowObjects ?

          F Da Costa wrote:
          [color=blue]
          > Ivo wrote:[color=green]
          > > "F Da Costa" wrote
          > >[color=darkred]
          > >>Small question re the use of an Array.
          > >>I'v got an array with x rowObjects in it.
          > >>When i get it the type of the container is Array and i can get a hold of
          > >>the objects just fine.
          > >>
          > >>owever, how do i get the length of the array?
          > >>For container.lengt h does not seem to work.[/color]
          > >
          > >
          > > You have misspelled the word length as lenght. Happens all the time.
          > > Or provide some clues by showing us some code.[/color]
          >
          > Point wel taken. Unfortunately there was no typo.
          > To make matters worse. When using the Venkman debugger the content of
          > the object (of type Array) showed the two HtmlRowTableEle ments just fine
          > and the parameter length said 0.
          >
          > Following the code:
          > ...
          > var ch = getChildSegment s(segment, 1);
          > if (ch.length>0)
          > displayDirectCh ildren(ch, onOff);
          > ...
          >
          > ch is filled correctly as verified in the debugger, breakpoint on the if
          > line.
          > The displayDirectCh ildren function is correct because this line is the
          > last one in that particular function (recursive call).
          >
          > TIA
          > Fermin DCG[/color]

          ch can exist such that (ch.constructor == Array) evaluates to true, it can
          contain information you have placed in it, and still have ch.length == 0.

          var a = new Array();
          a["a"] = "a";
          a["b"] = "b";
          alert(a.length) ;

          Without knowing how you are populating ch, it's difficult to tell if this is
          the problem or not. For example, you may be doing:

          var tableRows = new Array();
          tableRows["row0"] = row0;
          tableRows["row1"] = row1;
          // etc
          return tableRows;

          In which case, tableRows.lengt h will most certainly be 0.

          --
          Grant Wagner <gwagner@agrico reunited.com>
          comp.lang.javas cript FAQ - http://jibbering.com/faq


          Comment

          Working...