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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing values to a form in an IFrame

    Is it possible to pass variables to a input field in a form that is in an IFrame window?

    I've tried:
    Code:
     <div class="panel" id="PPpanel" align="center" style="display: none;">
    <iframe align="middle" frameborder="0" id="PPpanelIframe" name="PPpanelIframe" scrolling="auto" src="http://www.attwireless.com/ocs" title="Window" width="100%" height="300"></iframe>
    		</div>
    
    javascript: PPpanelIframe.LoginForm.min.value="attwireless";

    Code:
     <div class="panel" id="PPpanel" align="center" style="display: none;">
    <iframe align="middle" frameborder="0" id="PPpanelIframe" name="PPpanelIframe" scrolling="auto" src="http://www.attwireless.com/ocs" title="Window" width="100%" height="300"></iframe>
    		</div>
    
        var iframe = document.getElementById('PPpanelIframe');
        var minUser = iframe.document.getElementById('WirelessNo');
        var minPass = iframe.document.getElementById('Password');

    Please if any can help I appreciate it greatly!

  • #2
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    parent.html
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    	<head>
    		<title>Parent</title>
    	</head>
    	<body>
    		<iframe id="iframe" src="child.html"></iframe>
    		<input type="button" value="Go" onclick="document.getElementById('iframe').contentDocument.getElementById('txt').value = 'test successful';">
    	</body>
    </html>
    child.html
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    	<head>
    		<title>Child</title>
    	</head>
    	<body>
    		<input id="txt" type="text">
    	</body>
    </html>
    This works in Gecko browsers and Opera.

    Gecko DOM Reference

  • #3
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    can you get the same code as this to work in IE, i am trying to make a page that auto logs in another website by opening that page within a IFRAME

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    that's simple:

    document.getElementById('iframe').contentWindow.document.getElementById('txt').value = 'test successful';

    is cross-browser.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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