Results 1 to 4 of 4

Thread: passing variables to an iframe page

  1. #1
    Join Date
    Oct 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation passing variables to an iframe page

    Hi all,

    THis may sounds classic to some experts out there but I cannot google out the right answer. Here we go again:

    I have 1 main page(mainpage) and 2 iframes(ifram_left & iframe_right) within that main page. I have couple of checkbox and a drop downlist on the mainpage for navigation with a submit button (for ALL inputs selected) I dont know how to:
    a) capture the values (collectively) from those inputs and pass them to either iframes.
    b) pass variables from iframe_left to other inframe_right
    c) on either iframe page, how to receive passing variables from mainpage and/or the other iframe page for processing.

    Can some of you show me the way/links? Is cookie a better choice or??? Thanks in advance

  2. #2
    Join Date
    Apr 2006
    Location
    London
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Not sure about iframes, but here s what you can do with frames:

    http://javascript.internet.com/forms...ox-frames.html


    hope it helps,

    VatsaL

  3. #3
    Join Date
    Oct 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I found how i can pass the variable from a main page (form) to an Iframe page (form1) but I have a dilema. ..How do I automatically capture the value of the textfield in (Iframe) page after it is populated by sending page.
    How do I:
    a) run the function Show() when the textfield in iframepage is populated by the parent page (mainpage)
    b) how do parse/extract the passing value from the textfield (in iframepage).

    Thanks

    Here is my code for passing the variable.

    mainpage.

    <body>
    <form name="form" method="post" action="">

    <input type="text" name="textfield" />
    <input type="button" name="button" name="button"
    onclick="parent.frames['myIframe'].document.form1.textfield.value=
    this.form.textfield.value"/>
    </form>
    <p>
    <iframe name="myIframe" src="iframepage.htm"</p>
    </body>


    iframepage.

    <script type="text/javascript">
    {
    var x=document.getElementById("form1").textfield.value
    alert(x)
    }
    </script>
    <body>
    <form name="frame1" method="post">
    <input type="text" name="textfield" onclick="show()"/>
    <!-- onchange dont work here-->
    </form>
    </body>

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <script type="text/javascript">
    var copying = false;
    
    function copy(formName, fromName, frameName, frameFormName, toName) {
      if(!copying) return;
      var to = window.frames[frameName].document.forms[frameFormName].elements[toName],
        from = document.forms[formName].elements[fromName];
      to.value = from.value;
      window.setTimeout(function() { copy(formNum, fromName, frameName, frameFormName, toName); }, 300);
    }
    
    function beginCopy(formName, fromName, frameName, frameFormName, toName) {
      copying = true;
      copy(formNum, fromName, frameName, frameFormName, toName);
    }
    
    function endCopy() {
      copying = false;
    }
    </script>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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