Iframe Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lans Redmond

    Iframe Problem

    I have an iframe within a jsp page which displays rows from a database. I
    then have a checkbox where, when I check/uncheck the checkbox it performs
    operations on the rows listed in the frame.

    I get a jscript "undefined" error if 1 row is returned in the iframe. If I
    have more that 1 then my length for the iframe shows the amount. if only 1
    row is the iframe then my length comes up undefined


  • RobB

    #2
    Re: Iframe Problem

    Lans Redmond wrote:[color=blue]
    > I have an iframe within a jsp page which displays rows from a[/color]
    database. I[color=blue]
    > then have a checkbox where, when I check/uncheck the checkbox it[/color]
    performs[color=blue]
    > operations on the rows listed in the frame.
    >
    > I get a jscript "undefined" error if 1 row is returned in the[/color]
    iframe. If I[color=blue]
    > have more that 1 then my length for the iframe shows the amount. if[/color]
    only 1[color=blue]
    > row is the iframe then my length comes up undefined[/color]

    Very difficult to recommend anything without knowing what you're doing.
    Presumably a reference to 'the rows listed in the frame' is held in an
    array, and no array is generated if there's only one row, so you can't
    loop through it using the .length property. The fix is usually
    something like:

    obj = ('undefined' != typeof obj[0]) ? obj : [obj];

    ....where 'obj' is the (possible) array you're examining. Can't say more
    without seeing more.

    Comment

    • Lans Redmond

      #3
      Re: Iframe Problem

      All i'm doing is , i have a table wicth can have multiple rows or none, or
      even 1 depending on the search. I have this table in a jsp page. I then
      have another jsp where I link to my table via an iframe.
      Now for each row listed in the iframe i also build a checkbox. I use the
      foloowing to check and Uncheck all checkboxes in the frame.

      function verifyManualChe ckUncheck()
      {
      if (document.frame s[0].document.all.r esendtriggerlis t == null)
      {
      return;
      }
      if (checkFlag == false)
      {
      if (document.frame s[0].document.all.r esendtriggerlis t.length > 0)
      {
      for (i = 0; i <
      document.frames[0].document.all.r esendtriggerlis t.length; i++)
      {
      if (
      document.frames[0].document.all.r esendtriggerlis t[i].checked == true )
      {
      resendData +=
      document.frames[0].document.all.r esendtriggerlis t[i].value + ",";
      deleteData +=
      document.frames[0].document.all.r esendtriggerlis t[i].value + ",";
      }
      } //end for loop
      }
      }

      }

      now if one row is returned then this function fails. if i put an alert() to
      get the length of the iframe then it ldisplays undefined

      hope this is useful

      "RobB" <ferndoc9@hotma il.com> wrote in message
      news:1110602642 .086017.74410@o 13g2000cwo.goog legroups.com...[color=blue]
      > Lans Redmond wrote:[color=green]
      > > I have an iframe within a jsp page which displays rows from a[/color]
      > database. I[color=green]
      > > then have a checkbox where, when I check/uncheck the checkbox it[/color]
      > performs[color=green]
      > > operations on the rows listed in the frame.
      > >
      > > I get a jscript "undefined" error if 1 row is returned in the[/color]
      > iframe. If I[color=green]
      > > have more that 1 then my length for the iframe shows the amount. if[/color]
      > only 1[color=green]
      > > row is the iframe then my length comes up undefined[/color]
      >
      > Very difficult to recommend anything without knowing what you're doing.
      > Presumably a reference to 'the rows listed in the frame' is held in an
      > array, and no array is generated if there's only one row, so you can't
      > loop through it using the .length property. The fix is usually
      > something like:
      >
      > obj = ('undefined' != typeof obj[0]) ? obj : [obj];
      >
      > ...where 'obj' is the (possible) array you're examining. Can't say more
      > without seeing more.
      >[/color]


      Comment

      • kdarling@basit.com

        #4
        Re: Iframe Problem

        Lans, Rob already gave you the answer when he wrote "Presumably a
        reference to 'the rows listed in the frame' is held in an array, and no
        array is generated if there's only one row..." Read that carefully.
        This hits all of us at times. You could do something like:

        function verifyManualChe ckUncheck()
        {
        var theList = document.frames[0].document.all.r esendtriggerlis t;

        if (theList == null)
        return;

        // Check if only one e.g. not an array
        if (typeof theList[0] == 'undefined')
        {
        resendData += theList.value + ",";
        deleteData += theList.value + ",";
        return;
        }

        if (checkFlag == false)
        {
        if (theList.length > 0)
        {
        for (i = 0; i < theList.length; i++)
        {
        if ( theList[i].checked == true )
        {
        resendData += theList[i].value + ",";
        deleteData += theList[i].value + ",";
        }
        }
        }
        }
        }

        Comment

        Working...