0

Here's the scenario, we have applications that are iframed within our pages.

I have 2 pages, one will have a simple form:

    <form method="get" action="iframed.html">
    Zip Code:
    <input id="txtZipCode" type="text" name="ZipCode" />
    <input id="btnSubmit" type="submit" value="Submit" />
    </form>

And another that pulls the info into a form that is iframed within the page.

    <iframe src="blahblahForm.html" ></iframe>

How do I pull the Zip Code that was entered on the first page, and filled into the page with the iframed form?

Thank you

mark1178
  • 47
  • 1
  • 9

1 Answers1

0

Assuming the iframe src is in the same domain you can do this:

function setZipInIframe(zip){
   //load the input iframe and set a value
   getIframeDocument().getElementById('txtZipCode').value = zip;
}    


function getIframeDocument(){
            var iframe = document.getElementById("ifrId"); 
            //contentDocument because IE8 doesn't support contentWindow
            return (iframe.contentDocument || iframe.contentWindow.document);   
        }
fmodos
  • 4,472
  • 1
  • 16
  • 17
  • Thanks for the reply. Unfortunately it's not working. Thank you again. – mark1178 Jun 07 '13 at 13:28
  • ok, did you get any error? this is just a prototype on how to set a value in input named txtZipCode inside an iframe – fmodos Jun 07 '13 at 14:56
  • I didn't get any errors, here is my test link http://www.careington.com/test/agent11/form/index.aspx – mark1178 Jun 07 '13 at 16:32
  • @mark1178 I think I missunderstood your question... http://stackoverflow.com/questions/168455/how-do-you-post-to-an-iframe check if this post is what you are looking for – fmodos Jun 07 '13 at 17:26