Page 1 of 1

[SOLVED] Pass content from Frame to another

Posted: Sat Mar 12, 2005 1:23 am
by anjanesh
Let say a page has has 2 frames :
page0.htm

Code: Select all

<frameset cols="50%,*">
  <frame name="left" src="page1.htm">
  <frame name="right" src="page2.htm">
</frameset>
page1 has a textbox and a submit button.
When I hit the submit button is it possible to display value of textbox in page2 ?
I tried have a 'global' function in page0 where I did var v=document.getElementById("text1").value and set a page2's variable with this v. But this is not working ?
Possible ? If not any other way ?
Thanks

Posted: Sat Mar 12, 2005 2:23 am
by feyd
I believe..

Code: Select all

top.frames&#1111;'right'].getElementById('text1').value = 'whatever';

Posted: Sat Mar 12, 2005 2:38 am
by anjanesh
Thanks.
For searching :
Also works : - [Edit] DOES NOT WORK

Code: Select all

parent.frames['right'].getElementById('text1').value = 'whatever';
parent.frames[2].getElementById('text1').value = 'whatever';

Posted: Tue Mar 22, 2005 10:33 am
by anjanesh
Errata: (For those who end up here by searching)

Code: Select all

parent.frames['right'].getElementById('text1').value = 'whatever';
In order to change value of input type in another frame, parent.frames[framename].getElementById() cannot be used.
Instead a userdefined function in framename that updates the value must be called.
Frame 0: name : left

Code: Select all

.
<script type="text/javascript">
parent.frames['right'].UpdateText1('whatever');
</script>
.
Frame 1: name : right

Code: Select all

.
<script type="text/javascript">
function UpdateText1(NewValue)
 {
 	document.getElementById("text1").value = NewValue;
 }
</script>
.
<input type="text"; id="text1">
.