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

LVL 8
Sam CohenConsultant to Digital/DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

quincydudeCommented:
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.
HuyBDCommented:
You can use javascript with prefix parent
e.g
parent.frame1.document.forms[0].name.value="";
quincydudeCommented:
You can do something like this though
<html>
<body>
 
<iframe src="somepage.html" name="myiframe"></iframe>
 
 
<input type=button value="go" onclick="document.myiframe.formname.fieldname.value='test';"/>
</body>
</html>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sam CohenConsultant to Digital/DeveloperAuthor Commented:
So is it something like this:
<?php
$fname="Sam"
?>

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

quincydudeCommented:
You have to set a name for the iframe tag as in my code and replace the frame1 in your code with it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.