Link to home
Start Free TrialLog in
Avatar of jollykh
jollykh

asked on

Accessing hidden variable in parent frame

Hello,

I have a frame that encompasses two other frames: a top frame and a bottom frame.  I need to access a hidden variable in the bottom frame.  How can I do that?  Here's what I'm trying but i keep getting an error message:

top frame:
<script language="javascript">
function test()
{
  if(true)
  {
        alert(parent.positions.document.forms["order_positions"].test.value);
       return false;
  }
}
</script>

bottom frame:

<form action="something.do">
name="order_positions"
method="post"
target="_parent">

<input type=hidden name=test value="test">

</form>
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

If your bottom frame name is realy "positions", then use this:
alert(parent.positions.document.order_positions.test.value);

And in the upper snippet you have a closing > to ealy in the form tag. I hope this is a transcriptopn error.

Make sure that the for and it's fields are alredy loaded before accessing them.
Take a look on this ...
https://www.experts-exchange.com/questions/20913872/Hidden-Variable-and-Javascript.html
Avatar of mmayrell
mmayrell

You can try

parent.positions.document.getElementById("test").value

-Michael
Avatar of jollykh

ASKER

Ok, I think that this is going to be a little too difficult becuase there are frames within frames within frames.  Let me ask this question, becuase there are so many frames embedded in each other, is there a way that I can reload or refresh only the current frame that I'm in?
ASKER CERTIFIED SOLUTION
Avatar of mmayrell
mmayrell

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial