SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Inserting a form value into an iframe

    Hey,

    I have a webpage with an iFrame inside of it, and in the iframe there is a form with a simple input box, let's call it q1. There is also a form on my main page, which has an input box. Basically, I want it so that when a user enters a value into the main page's form and hits submit, that value gets placed into the input box of the iframe's form. Is this possible?
    Nick . all that we see or seem, is but a dream within a dream
    Show someone you care, send them a virtual flower.
    Good deals on men's watches

  2. #2
    SitePoint Member
    Join Date
    Jan 2008
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure exactly how to do that, but the first thing I would do is put a NAME identifier on the iFrame, so:

    HTML Code:
    <IFRAME SRC="page.html" NAME="iframe"></IFRAME>
    Then you can set the TARGET of the form to the iframe:

    HTML Code:
    <form method=\"POST\" action=\"[xxxx]\" target=\"iframe\">
    Hope that helps get you started...

  3. #3
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Easiest cross-browser solution to access an iframes DOM is the following:
    Code:
    var frame = window.frames["nameOfFrame"];
    
    // now you can access any element in the iframes DOM, example:
    alert(frame.document.getElementById("whatEverElementsIdInTheFrame"));
    Note though that submitting to the iframe will reloads its content.


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
  •