Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8767005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:41:48+00:00 2026-06-13T16:41:48+00:00

I have a form which uses the target attribute to target an iframe when

  • 0

I have a form which uses the target attribute to target an iframe when the form is posted which posts to a PHP script. This part is working fine but I need to do something based on several results that the php script will put in the iframe.

What I am thinking of doing is when the PHP script has finished posting it echo’s out some hidden input fields that contain various elements, such as the state of the post, whether it succeeded and what the final result was if it was successfully posted.

However, if I did this it would put it into the iframe so then the main web page wouldn’t be able to access the hidden input fields.

How would the main web page be able to access these hidden input fields so that the main web page can perform some action, I.e. make a div within the web page show a specific error message or whatever.

The other thing is, once I know how I can get the data from the hidden input field, how would I know when I can go and get the values. I was thinking that when the form is posted via a JavaScript document.forms["myform"].submit() code I could then do a while loop and check to see if another hidden input field status is set to complete and once it says complete I can then get the values from the hidden input field.

I’m not sure if the way I suggested is the right way or doing what I want to achieve or if there is a better way of doing it.

UPDATE

I’ve tried what @lanzz suggested but it doesn’t appear to have worked. Below is what I have tried.

$("iframe#image_upload_frame").on('load', function()
{
   var iframeBody = this.contentDocument.body;


   var data = $(iframeBody).find("#imageDirectory");
   alert("data: " + data);
});

Below is how the iframe is defined

<iframe id="image_upload_frame" name="image_upload_frame"></iframe>

and I am echoing out a hidden input field in the php script that’s within the iframe.

echo '<input type="hidden" id="imageDirectory" value="'.$imageDirectory.'" />';

The echo is definetly working as when I see view the iframe source I can see the hidden input however, the alert dialog is never shown as if something isn’t working. There are no errors being reported either by the google chrome dev console.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:41:49+00:00Added an answer on June 13, 2026 at 4:41 pm

    If I understand correctly – you need a value from the iframe in the parent window, once the value is loaded into the iframe. I would add javascript to the iframe calling the parent and executing a function.

    In the main frame:

    function incomingValue(val) {
       alert(val)
    }
    

    and somewhere in the generated iframe:

    <script type="text/javascript">
     parent.incomingValue("Hello world");
    </script>
    

    This should work assuming both frame sources share the same domain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form which uses $.ajax on submit to call a bash script
I have this login form which uses AJAX to query a database for checking
I have a simple contact form which uses jquery to post to a php
I have a form which submits to an iFrame (this is a common approach
I have a form which uses the GET method. This might be a stupid
I have a form which runs inside an Iframe and uses the excellent postmessage
We have a form which uses the JQuery Validation Plugin and would like to
I have the following form for photo_album which uses the nested forms feature of
i have an form which will send some data to an php file ,
I have an application which uses 2 forms, a Main Form and a Splash

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.