Reading parent variable into iframe

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
mrojek
New User
Posts: 12
Joined: Fri Nov 30, 2012 3:48 pm
First Name: Mike
Last Name: Rojek
Company Name: McGard
State / Province: New York
Zip / Postal Code: 14127
Country: United States
Contact:

Reading parent variable into iframe

Post by mrojek »

I am currently working on a program that will require an iframe to read data from the display screen when the screen is loaded. So far I have had no luck reading in anything to the iframe. Here is a section of my javascript code for the iframe:

<p id="Var1"></p>
<p id="Var2"></p>
<script type="text/javascript">
document.getElementById("Var1").innerHTML = txtVar1;
document.getElementById("Var2").innerHTML = parent.document.getElementById(window.txtVar1);
</script>

These attempts that I have made in the javascript have not worked for me.
Is this even possible with using the profound iframe widget or am I not coding this correctly?
Any information you could give me would be great

Thanks
Attachments
demo.rpgle.txt
(396 Bytes) Downloaded 55 times
demo.dspf.txt
(3.09 KiB) Downloaded 56 times
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Reading parent variable into iframe

Post by Scott Klement »

Assuming your goal is to retrieve the contents of the textbox named 'txtVar1' in the parent frame, you could do that like this:

Code: Select all

var myVar = parent.pui.get("txtVar1");
The code that you provided as an example is using a Javascript variable named txtVar1 instead of looking for a DOM element with that name.
mrojek
New User
Posts: 12
Joined: Fri Nov 30, 2012 3:48 pm
First Name: Mike
Last Name: Rojek
Company Name: McGard
State / Province: New York
Zip / Postal Code: 14127
Country: United States
Contact:

Re: Reading parent variable into iframe

Post by mrojek »

Scott,

Works perfectly! Thanks for the quick reply!
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests