How to add array elements to parent window from child window

M

markrandolph

I have parent.htm and child.htm
=================================================================
In parent.htm we have:

var parentarray = new Array(5)
window.open("child.htm",.....)

=================================================================
In child.htm I want to add new elements to parentarray, like
opener.parentarray[6] = .......
 
M

markrandolph

Actually here is a more accurate desc of the prob:

parent.htm:

function parentarrayobject(last,first)
{
this.last = last
this.first = first
}
var parentarray = new Array()
parentarray[0] = new parentarrayobject("sixpack","joe") // this works
ok
window.open("child.htm",.....)
=================================================================
child.htm:
//--> the alert works, pops up with "object"
alert(typeof(opener.parentarrayobject))
//--> the next statement chokes... "Invalid procedure call or
argument"
opener.parentarray[1] = new
opener.parentarrayobject("fivepack","jane")
=================================================================
The problem is when trying to create parentarray[1] in child.htm it
keeps giving "Invalid procedure call or argument"
 
S

SAM

Le 10/25/08 2:17 AM, (e-mail address removed) a écrit :
I have parent.htm and child.htm
=================================================================
In parent.htm we have:

var parentarray = new Array(5)
window.open("child.htm",.....)

=================================================================
In child.htm I want to add new elements to parentarray, like
opener.parentarray[6] = .......


And ?

That doesn't work ?

That would have to.
 
S

SAM

Le 10/25/08 11:10 PM, (e-mail address removed) a écrit :
Actually here is a more accurate desc of the prob:

try :

mother.htm :

<script type="text/javascript">
var tabl = [11,'hello',3];
</script>
</head>
<body>
<h1>parent</h1>
<p><button onclick="window.open('child.htm');">daughter</button>
<button onclick="alert(tabl)">voir </button>


child.htm :

<body>
<h1>children</h1>
<form action="#"
onsubmit="opener.tabl.push(this.elemt.value); return false;">
element to add : <input type="text" name="elemt">
<input type="submit" value="add">
</form>
<form action="#"
onsubmit="opener.tabl[this.indx.value] = [
this.val1.value,
this.val2.value
];
return false;">
index of element to modify : <input type="text" name="indx" size="5">
value 1 : <input type="text" name="val1">
value 2 : <input type="text" name="val2">
<input type="submit" value="modify">
</form>
<button onclick="alert(opener.tabl)">see the opener's array </button>
</body>


works with IE and Fx
 
S

SAM

Le 10/26/08 2:03 AM, Conrad Lender a écrit :
onsubmit="opener.tabl[this.indx.value] = [
this.val1.value,
this.val2.value
]; ..
works with IE and Fx

Sure, but it doesn't do what the OP was describing. It just adds an
array to the array in opener, not a new object. As I said earlier, the
array isn't the problem.

object or array what importance ?

the x element of original mother's array is changed in a new sub-array

if object is realy absolutly wanted :

onsubmit="opener.tabl[this.indx.value] = {
'name': this.val1.value,
'firstname': this.val2.value
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top