user1011713
user1011713

Reputation: 279

Passing textarea values from an iframe to the parent form without clicking submit

I have a regular form that asks for several inputs and half-way down, an iframe window that does an auto-suggest much similar to this here: http://code.drewwilson.com/entry/autosuggest-jquery-plugin.

My form looks similar to this: When I click to submit, which is located in the parent window, the loaded values in the textarea of my auto-suggest, which is loading in the iframe do not pass values back to the parent form.

I have researched and tried many suggestions included a parent tag. When I get rid of the iframe and dump everything into the regular form, the auto-suggested values pass with the form submission so I know it works.

I apologize for the somewhat poor quality of my problem; the whole situation is very hard to explain.

Upvotes: 0

Views: 1295

Answers (1)

Will P.
Will P.

Reputation: 8787

In jquery you can set object values, in this case probably a hidden input field, in the parent of an iframe by passing the window.parent.document as a parameter into it. I think you want something like this inside the IFrame:

$('#id_of_text_input_element').change(function (){ 
    $('#hidden_text_element_id', window.parent.document).val($(this).val());
});

then you can grab the value of the hidden element from the server side code on the submit event.

Upvotes: 1

Related Questions