469,343 Members | 5,478 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

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
Jul 23 '05 #1
3 1474
Lans Redmond wrote:
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


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.

Jul 23 '05 #2
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 verifyManualCheckUncheck()
{
if (document.frames[0].document.all.resendtriggerlist == null)
{
return;
}
if (checkFlag == false)
{
if (document.frames[0].document.all.resendtriggerlist.length > 0)
{
for (i = 0; i <
document.frames[0].document.all.resendtriggerlist.length; i++)
{
if (
document.frames[0].document.all.resendtriggerlist[i].checked == true )
{
resendData +=
document.frames[0].document.all.resendtriggerlist[i].value + ",";
deleteData +=
document.frames[0].document.all.resendtriggerlist[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" <fe******@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Lans Redmond wrote:
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


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.

Jul 23 '05 #3
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 verifyManualCheckUncheck()
{
var theList = document.frames[0].document.all.resendtriggerlist;

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 + ",";
}
}
}
}
}

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Christopher J. Hahn | last post: by
12 posts views Thread by wangzx | last post: by
26 posts views Thread by shlomi.schwartz | last post: by
7 posts views Thread by nicknack | last post: by
reply views Thread by mem | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.