Finding the parent of an iframe with jquery

I’m using dynamically created upload fields that are in iframes.
(There is an “add another” button.) After uploading the file in the iframe, the file path is passed back to a hidden field in the form.

The tricky part is passing the data back to the correct hidden field since the name can’t be determined ahead of time. Passing the data through $_GET or $_POST data is highly problematic.

So is there a way to find the div that contains the iframe from within the iframe.

Thanks E

I think you can do something like this in the iframe;


var myDiv = parent.document.getElementById("myDivId");

Right, the problem is the id is unknown because its created dynamically. So I was trying to find the parent element rather than the parent page.

I figured out how to do this, though its somewhat convoluted. A function on the parent page cycles through the input fields and gathers the data. The function is triggered from inside the iframe when the upload is complete.

E