#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    17
    Rep Power
    0

    How to set value inside iframe


    How can we set a value to iframe textbox element either in JS/Jquery
    Code:
    <head> <script type="text/javascript"> function load() { alert("Frame is loaded"); myframe.document.getElementById("user_email").value = "<?php echo $var ?>"; } </script> </head> <body> <iframe onload="load()" id="myframe" name="myframe" src="http://www.gigpayrr.com/signup" width="700px" height="600px"> <p>Your browser does not support iframes.</p> </iframe> </body>
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,041
    Rep Power
    119
    You need to use the window.frames[] method or the contentWindow/contentDocument method; to access your iframe. Although, I think the window.frames[] method is the easiest way, to do this.
    Code:
    window.frames["myframe"].document.getElementById("user_email").value = "<?php echo $var ?>";

IMN logo majestic logo threadwatch logo seochat tools logo