Pass variables to a iframe form

Posted on 2008-11-11
Last Modified: 2012-05-05
Is there anyway to let say.
I have a page with vars define:

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

Question by:Sam Cohen
    LVL 15

    Expert Comment

    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.
    LVL 17

    Expert Comment

    You can use javascript with prefix parent
    LVL 15

    Accepted Solution

    You can do something like this though
    <iframe src="somepage.html" name="myiframe"></iframe>
    <input type=button value="go" onclick="document.myiframe.formname.fieldname.value='test';"/>

    Open in new window

    LVL 8

    Author Comment

    by:Sam Cohen
    So is it something like this:

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

    LVL 15

    Expert Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now