473,698 Members | 2,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to add array elements to parent window from child window

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

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

=============== =============== =============== =============== =====
In child.htm I want to add new elements to parentarray, like
opener.parentar ray[6] = .......
Oct 25 '08 #1
7 5323
On 2008-10-25 02:17, ma**********@ju no.com wrote:
In parent.htm we have:
var parentarray = new Array(5)
window.open("ch ild.htm",.....)
In child.htm I want to add new elements to parentarray, like
opener.parentar ray[6] = .......
And your problem is...?
- Conrad
Oct 25 '08 #2
Actually here is a more accurate desc of the prob:

parent.htm:

function parentarrayobje ct(last,first)
{
this.last = last
this.first = first
}
var parentarray = new Array()
parentarray[0] = new parentarrayobje ct("sixpack","j oe") // this works
ok
window.open("ch ild.htm",.....)
=============== =============== =============== =============== =====
child.htm:
//--the alert works, pops up with "object"
alert(typeof(op ener.parentarra yobject))
//--the next statement chokes... "Invalid procedure call or
argument"
opener.parentar ray[1] = new
opener.parentar rayobject("five pack","jane")
=============== =============== =============== =============== =====
The problem is when trying to create parentarray[1] in child.htm it
keeps giving "Invalid procedure call or argument"
Oct 25 '08 #3
On 2008-10-25 23:10, ma**********@ju no.com wrote:
Actually here is a more accurate desc of the prob:
...
child.htm:
//--the alert works, pops up with "object"
alert(typeof(op ener.parentarra yobject))
//--the next statement chokes... "Invalid procedure call or
argument"
opener.parentar ray[1] = new
opener.parentar rayobject("five pack","jane")
=============== =============== =============== =============== =====
The problem is when trying to create parentarray[1] in child.htm it
keeps giving "Invalid procedure call or argument"
Your script is working fine, except in Internet Explorer (please mention
that the next time!). Not sure what the cause is, except that it's not
related to the array. It also occurs if you only write
"new opener.parentar rayobject()". For some reason IE won't let you
create objects from a constructor that was defined in the parent window.

As a workaround, you could try calling a function in the opener, and
have the new parentarrayobje ct created there.
- Conrad
Oct 25 '08 #4
SAM
Le 10/25/08 2:17 AM, ma**********@ju no.com a écrit :
I have parent.htm and child.htm
=============== =============== =============== =============== =====
In parent.htm we have:

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

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

And ?

That doesn't work ?

That would have to.

--
sm
Oct 26 '08 #5
SAM
Le 10/25/08 11:10 PM, ma**********@ju no.com 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.ht m');">daughter</button>
<button onclick="alert( tabl)">voir </button>
child.htm :

<body>
<h1>children</h1>
<form action="#"
onsubmit="opene r.tabl.push(thi s.elemt.value); return false;">
element to add : <input type="text" name="elemt">
<input type="submit" value="add">
</form>
<form action="#"
onsubmit="opene r.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)">s ee the opener's array </button>
</body>
works with IE and Fx
--
sm
Oct 26 '08 #6
On 2008-10-26 02:43, SAM wrote:
onsubmit="opene r.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.

Something along these lines might work (untested):

// in parent:
function Person (first, last) {
this.first = first;
this.last = last;
}
function addPerson (first, last) {
persons.push(ne w Person(first, last));
}
var persons = [];
persons.push(ne w Person("Joe", "Sixpack")) ;

// in child:
opener.addPerso n("Jane", "Fivepack") ;

This way the Person object is created in the same frame/window that also
holds its constructor. Maybe that'll make IE happy.
- Conrad
Oct 26 '08 #7
SAM
Le 10/26/08 2:03 AM, Conrad Lender a écrit :
On 2008-10-26 02:43, SAM wrote:
> onsubmit="opene r.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="opene r.tabl[this.indx.value] = {
'name': this.val1.value ,
'firstname': this.val2.value
};

--
sm
Oct 26 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2223
by: Sims | last post by:
Hi I have a table with something like ID PARENT 0 | -1 1 | -1 2 | 1 3 | 1
4
13084
by: John MacIntyre | last post by:
Hi, I have a page with a series of child pages loaded into an iframe. When I move from page to page, I store an object containing the child's control data in a variable on the main page, then use that data to populate the controls when the child page is opened again. One of these objects contains an Array, and the page reloads fine using myArray, myArray, etc... But when I try perform some array methods on it (i.e.slice) ... it does...
1
1783
by: mrhicks | last post by:
Hello all, I need some advice/help on a particular problem I am having. I have a basic struct called "indv_rpt_rply" that holds information for a particular device in our system which I will call INDV. The struct looks like // Some info used for the struct typedef unsigned char uint8; /* 8 bits */
2
23501
by: Raj | last post by:
Hi All, I have a problem with trying to refresh the parent window from child window in order to update data in the parent window. The sequence of events are 1) I click a button in the parent window to open a child window thru javascript window.open 2) I have some functionality in the child window that changes the data
1
11574
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at http://weblogs.asp.net/asmith/archive/2003/09/15/27684.aspx but it was far more complex then I needed. (I got lost trying to figure it all out). Therefore, here goes my simple "web dialog box with parent event handler fireing" solution. ...
5
3834
by: Manish | last post by:
This is the print_r() for a variable $categories. $categories :: Array ( =Array ( =Array (
1
1861
by: Carlos Aguayo | last post by:
If I have a parent and a child window, and if I create an array in the child window, and pass it as a parameter to the parent window, it's still an array, and its methods still work (like the 'forEach'). However, if I try to figure out if it's an array by looking at the constructor property, I get that it's not an array. I got this behavior in IE6 and Firefox, is this a bug or am I doing something wrong? I pasted the code below. Thanks!...
1
4920
by: Richard Harter | last post by:
On Fri, 27 Jun 2008 09:28:56 -0700 (PDT), pereges <Broli00@gmail.comwrote: There are some obvious questions that should be asked, e.g., is the contents of your array already sorted as your example implies. If they are then all you need to do is find the element at index k = n/2 and then increase k until you find an element that differs from A. Then k is the number of left children and n-k is the number of right children. (Fencepost...
4
3975
by: Buddha | last post by:
Hello, I posted this on two forums, without too much help .. and I am kinda stuck in this. I need to refresh the parent page from the second child window which is opened by the first child and the first child window closes after opening the second child. This is the second time I am typing the post, I lost all content because the site complaine I was using the lesser than symbol.
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.