PDA

View Full Version : array problems


safalkishore
03-14-2003, 07:36 AM
multidimension array problems

hi all
i am facing a problem with multidimension array while i try and access the same from a popup window and modify the actual array in the parent window.

This is what i am trying
1)I have an array in the main window
2)Onclick on a link i open a popup window
3)The popup window adds new values to the array in the parent window
4)Once the addition is done the popup window is closed
5)Then again i try and open the popup window to add more values

This is when an error throws up - "Callee not found"

ie although the popup window has modified the array in the main window it fails to access the newly added array item

The main window shows the new added value though

Any solutions ????

Check below for code

Main Window

<SCRIPT LANGUAGE=javascript>
<!--
var tempArray = new Array();
for(i=0;i<2;i++)
tempArray[i]=new Array()

tempArray[0][0]="AAA"
tempArray[0][1]="ZEN2"
tempArray[1][0]="BBB"
tempArray[1][1]="ZEN1"

function winOpen()
{
alert(tempArray.length)
//alert(tempArray)
for(i=0;i<tempArray.length;i++)
{
alert(tempArray[i][0])
alert(tempArray[i][1])
}

oWin = window.open("popup.htm")
}
//-->
</SCRIPT>


PopUP Window

<SCRIPT LANGUAGE=javascript>
onload=init();
<!--
function init()
{
HeadLen=window.opener.tempArray.length;

var Headingarr = new Array();
for(i=0;i<HeadLen;i++)
Headingarr[i]=new Array()

alert(window.opener.tempArray.length)

for(i=0;i<HeadLen;i++)
{
alert(window.opener.tempArray[i][0])
alert(window.opener.tempArray[i][1])
}


for(i=0;i<HeadLen;i++)
{
Headingarr[i][0]=window.opener.tempArray[i][0];
Headingarr[i][1]=window.opener.tempArray[i][1];
}

//alert(Headingarr)
//window.opener.tempArray[window.opener.tempArray.length]=window.opener.tempArray.length;

val=window.opener.tempArray.length
//alert(val)
window.opener.tempArray[val]=new Array()
window.opener.tempArray[val][0] = "CCC"
window.opener.tempArray[val][1] = "ZEN3";

//alert(window.opener.tempArray)
var Headingarr = null;

self.close();
}
//-->
</SCRIPT>

I am constructing a table dynamically from an array in the main window

In the popup wwindow i am adding a new column to the table ie i am modifying the array and calling back the same function that creates the table with an addidtional column

This is where i am trying to apply this logic]

Any help on the same would be great

joh6nn
03-15-2003, 09:54 PM
i'm just wondering why you open the new window to do this. i don't think that's the problem ( i don't actually see a problem, right off the bat ), bit i'm just wondering why you're doing that.

like i said, i don't immediately see a problem, so, which browser are you testing this in, can we see the page this is on, are there any other scripts being used, etc?

paulstreats
03-16-2003, 12:00 AM
Same thoghts as above, I just had a quick look throuth and noticed that your first FOR loop doesn't have a { to mark its start point or a } to mark its finishing point, don't know if this helps?