Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2005
    Location
    Camino, California.
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help setting a variable in a frame's frame to the variable in the main page.

    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?
    Last edited by cameronlanni; 10-16-2005 at 01:59 AM.

  • #2
    New Coder
    Join Date
    Oct 2005
    Posts
    87
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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:
    Code:
    <script>
    document.forms[0].elements[0].value = classf;
    </script>
    
    <form name="test">
    <input type="hidden" name="tst" value="">
    </form>
    Then in frame 3 access it by:
    Code:
    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.

  • #3
    New Coder
    Join Date
    Oct 2005
    Location
    Camino, California.
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow. I got it. Thank you so much!
    Last edited by cameronlanni; 10-16-2005 at 04:24 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •