Link to home
Start Free TrialLog in
Avatar of Sam Cohen
Sam CohenFlag for United States of America

asked on

Pass variables to a iframe form

Is there anyway to let say.
I have a page with vars define:
$fname="Jon";
$lname="Doe";
$email="john.doe@nothing.com";

and i have a button and a Iframe on the same page anf in the iframe shows any site where is says;
enter you first name, last name, email address in form fields

Is there anyway, if after i click the button, transfer the vars to the form fields?
The form fields are firstname, lastname, email

Avatar of quincydude
quincydude
Flag of Hong Kong image

Do you mean getting php variables?
It's impossible for javascript to read php variables unless you write them to the html and store them as inputs manually.
You can use javascript with prefix parent
e.g
parent.frame1.document.forms[0].name.value="";
ASKER CERTIFIED SOLUTION
Avatar of quincydude
quincydude
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sam Cohen

ASKER

So is it something like this:
<?php
$fname="Sam"
?>

<script>
function Onsubmit()
{
parent.frame1.document.forms[0].name.value="<?php $fname; ?>";
}
</script>

You have to set a name for the iframe tag as in my code and replace the frame1 in your code with it.