473,545 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

parent.document problem

I have a page(pg1) which contains a select list (list1) in a
form(form1) and an iframe(frame1), in this iframe is a page(pg2) with
another select list(list2) in a form(form2) and I transfer the
contents of list2 to list 1 as follows

function transfer(){
for (var i=0; i<document.form 2.list2.length; i++){
var cf=document.for m2.list2;
addOption(paren t.document.form 1.list1, document.form2. list2[i].value,
document.form2. list2[i].value);
}
}
function addOption(selec tbox,text,value ){
var optn = document.create Element("OPTION ");
optn.text = text;
optn.value = value;
selectbox.optio ns.add(optn);
}

Now this works ok BUT my problem is this stops working when I display
pg1 from inside another iframe(frameA)
The error is in parent.document .form1.list1 is null or not an object,
how do I get access to list1 in this situation

Oct 19 '06 #1
2 13782
ASM
Steven a écrit :
I have a page(pg1) which contains a select list (list1) in a
form(form1) and an iframe(frame1), in this iframe is a page(pg2) with
another select list(list2) in a form(form2) and I transfer the
contents of list2 to list 1 as follows
function tansfer(from,to ) {
to.length = 0;
for(var i=0; i<from.length; i++)
{
to.options[i].value = from.options[i].value;
to.options[i].text = from.options[i].text;
}
}
If all your elements are nammed ( name="...")

<a href="#"
onclick="transf er('document.fo rm1.list1',
'parent.frame1. document.form2. list2');
return false;">transfe r</a>

If all your elements has an id :

<a href="#"
onclick="transf er('document.ge tElementById('l ist1'),
'parent.frame1. document.getEle mentById('list2 '));
return false;">transfe r</a>

Case form1 in an iframe (frameA) and form2 in other iframe (frame1) :

- calling from iframeA (where is form1)

<a href="#"
onclick="transf er('document.fo rm1.list1',
'parent.frame1. document.form2. list2');
return false;">transfe r</a>
- calling from main page (whith both iframes)

<a href="#"
onclick="transf er('parent.fram eA.document.for m1.list1',
'parent.frame1. document.form2. list2' );
return false;">transfe r</a>

function transfer(){
for (var i=0; i<document.form 2.list2.length; i++){
var cf=document.for m2.list2;
addOption(paren t.document.form 1.list1, document.form2. list2[i].value,
document.form2. list2[i].value);
}
function transfer(){
var from = (typeof(parent. iframeA)!='unde fined')?
parent.iframeA. document : document;
from = from.form1.list 1;
var to = parent.iframe1. form2.list2;
to.length = 0; // if you don't want to add but to replace
for(var i=0; i<from.length; i++)
addOption(to, from[i].text, from[i].value);
}
}
function addOption(selec tbox,text,value ){
var optn = document.create Element("OPTION ");
optn.text = text;
optn.value = value;
selectbox.optio ns.add(optn);
or :
var optn = new Option(value, text);
selectbox[selectbox.lengt h] = optn;
}

Now this works ok BUT my problem is this stops working when I display
pg1 from inside another iframe(frameA)
The error is in parent.document .form1.list1 is null or not an object,
of course, you forgive the iframe ... !
parent.frameA.d ocument.form1.l ist1
or, if called from iframe 'frameA', you can also do :
document.form1. list1

--
ASM
Oct 19 '06 #2

Thanks ASM for your help I got it working
Steven

Oct 20 '06 #3

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

Similar topics

1
10085
by: Winfried Koenig | last post by:
Hi everyone, I have a main page: -------------------------------------------------- <html><head><title>Test</title> </head><body> <img id="img_a" name="img_a" src="image_1.png" alt=""><br>
2
1412
by: Adrian MacNair | last post by:
I have a question in the child and I need to pass the answer back to the parent: var go = 0 var mywin = null; opts = 'width=300,height=300,status=yes,toolbar=no,menubar=no,location=no' mywin = window.open('','mywin',opts) mywin.document.open() mywin.document.write('<html><head><title>My Title</title>' +'<script type="text/javascript">'
1
1950
by: Bill Borg | last post by:
Hello all, Simple chat app, where the site owner has a master window with all requests for chat, status of each room, etc., and child windows for each separate chat in which the owner is engaged. When the owner closes one of his child windows, I want to update the master window. I understand "reasonably" well how to go about this. The...
5
4594
by: Peter | last post by:
1) I have a C# web application and what I am trying to do is create a popup window from a link on the parent window 2) the popup window will have a button and when a user clicks on the button the program should update a database, close the window and refresh the parent window. My question is does anyone have a example of popup window wich will...
10
3993
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms,...
6
9366
by: paul | last post by:
HI! How do we send a variable from an Iframe page back to its parent? I have a script that calculates the iframe's window size but I need to know how to send that value back to its parent so I can use it there. Thanks in advance :) Paul
4
9664
by: Phil Powell | last post by:
I thought this would work but it seems to not work neither in Netscape nor in IE: <script type="text/javascript"> <!-- // OBTAINED FROM http://www.javascripter.net/faq/settinga.htm // NOTE THAT IF YOU SET days TO -1 THE COOKIE WILL BE SET TO YESTERDAY
4
2904
by: patrizio.trinchini | last post by:
Hi all, I'm new to XSLT and maybe my problem have a very trivial answer, but I need an expert that point me in the right direction. What I would obtain is to remove all the elements that have a child element with an attribute set at a given value; maybe an example is more self-explaining... Given the following input XML document:
7
1660
by: maralfarshadi | last post by:
Dear All I am working on a Java based Web app - In this application, a window contains many textboxes which open the same child window. The user should choose among the option boxes provided and the choice should be reported back to parent window. 1. To know which textbox caused the child window to open, the two hidden inputs namely cbox...
0
7428
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...
1
7452
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...
1
5354
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...
0
5071
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3485
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
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
1
1039
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.