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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    div fields not working

    Hi, ive got 1 div field in a iframe, and i got another iframe trying to adjust that div field, i am using

    parent.document.getElementById("THEFIELD").innerHTML = WHATEVER;

    which i guess is wrong because it isnt working any clue what to do ?

  • #2
    New Coder
    Join Date
    May 2005
    Location
    New Zealand
    Posts
    76
    Thanks
    0
    Thanked 6 Times in 6 Posts
    There are possibly 2 problems with this,

    the first is that 'getElementById' returns a pointer to the object so if you want to use this you will have to do

    Code:
       the_div = parent.iframe_1.document.getElementById("THEFIELD");
       the_div.innerHTML = WHATEVER;
    Note that you probably don't need to get the element by id, you should be able to set the innerHTML directly as seen in the example below.

    The other Problem could be that because the div is in an iframe you need to include the name of the iframe in the code to access the div.

    For example if the div "div_1" is in "iframe_1" and you are trying to do something with it from "iframe_2" the code might need to be

    Code:
       parent.iframe_1.div_1.innerHTML = WHATEVER;
    Hope this helps, let me know how you get on.


  •  

    Posting Permissions

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