View Full Version : Need help setting a variable in a frame's frame to the variable in the main page.

10-16-2005, 01:40 AM
I have a main page. On that page, I have two frames (frames a and b), and in frame b, I have yet another frame (we'll call this frame c.) I have a variable on my main page that holds a string. I am trying to make a variable on frame c that copies it's value from whatever the variable on the main page is. I'm using this code:

var classf = parent.parent.document.classf;

classf is the name of both the variable on the main page and the name of the variable in frame c. No matter what I try, I can't seem to get it to work. Any suggestions?

10-16-2005, 04:53 AM
To access frames, forms, and elements just reference them by their index number.

You could assign the variable in frame 0 to a hidden input tag like:

document.forms[0].elements[0].value = classf;

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

Then in frame 3 access it by:

var classf = parent.frames[0].document.forms[0].elements[0].value;

Just change the index number if you have more than one form or element on the same page.

10-16-2005, 05:07 AM
Wow. I got it. Thank you so much! :thumbsup: