views:

2080

answers:

3

I am using JQuery's thickbox to input form data. Would like to auto close the thickbox and send a variable back to the parent from the thickbox form input upon submit.

A: 

Depending on how you're showing the Thickbox popup, there are going to be different ways to accomplish what you want.

If you're using an IFRAME popup, there is no way (that I know of) to pass the value back to the parent.

If you're using inline content (what I would suggest for this purpose), the value will still be available to you after Thickbox hides the inline content. You can then use jQuery to access the fields that the user filled in.

Justin Niessner
I would be using inline but I am a bit of a JQuery n00b and there is not a lot of details on how to do this with JQuery. Any ideas if I have a textbox element id=textName in the parent how I might get it back from the child?
dvancouver
+2  A: 

You can send data back to the parent with an iframe thickbox:

On your parent, you can write a function to handle this data:

function new_info(from_form) {
  $('#thing).text(from_form);
}

Then simply call this function in your submit function (or whereever) from the iframe page using parent:

$('#myForm').submit(function(){
  parent.new_info($('#phone_number').val());
});
Rob
Thanks, its help me (but I'm using top.function_name();). +1
ARTstudio
A: 

Here is an awesome article Upload in modal window and pass values with jQuery.

Big thanks for author. It saved me pretty amount of time.

Matthew