3

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!

3
  • How do you know it doesn't change the value? If alert gives you new value it seems to me it's working ok. Commented Aug 21, 2009 at 6:27
  • Do you load jquery in the iframe, or is it only available in the main frame? Commented Aug 21, 2009 at 7:13
  • jQuery is loaded in both frames. The reason I know the value isn't changed is because I inspect it with Firebug and the new directory isn't sent by the form. Commented Aug 21, 2009 at 7:29

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I used a variation of this technique. Thank you for the tip!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.