tags:

views:

205

answers:

1

Hey,

I have a form inside an iframe that needs to be manipulated from the main frame.

The iframe is viewed in a pop-over when a button is clicked in the main frame. It then contains a upload form with a hidden field called dir.

I want to set the hidden field before showing the form. I tried:

$('#upload_iframe').contents().find('#dir').val(dir);

... which runs. And the new value can be printed with alert() in the main frame. However, the iframe doesn't change it's value. Can you help me figure out why?

Thank you!

+1  A: 

I don't believe this is possible in a single line of jQuery. The solution I can think of is somewhat more convoluted.

The IFrame will have a source page (say, test.aspx, for example). To get a text box on that page to be posted you can set the URL to include the text:

$("#upload_iframe").attr("src", "text.aspx?dir=YourDirTextHere");

Then in your server side code you would pick this up off the querystring.

James Wiseman
I used a variation of this technique. Thank you for the tip!
Christoffer
No worries. Maybe vote up when you get to 15 :-)
James Wiseman