Quantcast

return value from shadowbox(child page) to parent page

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

return value from shadowbox(child page) to parent page

Akwolf
I have been looking for a way to return a values from my shadowbox windows back to the parent.  It seems shadowbox doesn't have an api to do so.  Can someone help my out on this?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: return value from shadowbox(child page) to parent page

Joseluis
a mi tambien me gustaria saber como controlar el retorno del valor de la ventana shadow.
si es que no existe la forma por favor implementenlo
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: return value from shadowbox(child page) to parent page

startail
In reply to this post by Akwolf
It's quite simple actually, you use Javascripting for that.

Here's an example.

<script type='text/javascript'>
	parent.$('input#address').val('{$address}');
	parent.$('input#postalcode').val('{$postalcode}');
	parent.$('input#postalcity').val('{$postalcity}');
	parent.$('input#latitude').val('{$latitude}');
	parent.$('input#longitude').val('{$longitude}');
	parent.$('span[name=address]').text('{$address}');
	parent.$('span[name=postalcode]').text('{$postalcode}');
	parent.$('span[name=postalcity]').text('{$postalcity}');
	parent.Shadowbox.close();
</script>

This uses jQuery to, but you get the hang of it I hope.
Just use the way you usually use for parsing data to a place in your first page with Javascript, just add "parent." before it and it will work.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: return value from shadowbox(child page) to parent page

ThisIsMe
You can also do it without JQuery by referencing an element in your parent document with 'parent.document' from your Shadowbox.

For example, say you have index.html. In this you have one text box and a link to open a shadowbox:
Address from Shadowbox: <input type="text" id="parentAddress" />
<a rel="shadowbox;height=300;width=300" href="shadowbox.html">Open Shadowbox</a>
In shadowbox.html, you might have another text box that you enter data into and a button that when clicked calls a javascript function:
Address to send to Parent: <input type="text" id="shadowboxAddress"/>
<input type="button" onclick="returnToParent()" value="Close Shadowbox"/>
The returnToParent() function sends the text from the input text box to the parent using 'parent.document' and closes the Shadowbox:
<script type="text/javascript">
    function returnToParent()
    {
        parent.document.getElementById('parentAddress').value = document.getElementById('shadowboxAddress').value;
        self.parent.Shadowbox.close();
    }
</script>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: return value from shadowbox(child page) to parent page

José Chafardet
what about, if i dont have a text field,but text links?

lets asume the following scenario

parent page form:

hidden field (id)
text field (title)

shadowbox iframe
(id)   (title)
1    - RHEL 4.0 for non nix user

(tho i need to return 2 values, the book id, and the book title, in a single click)

how could that be done?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: return value from shadowbox(child page) to parent page

I.Nishida
In reply to this post by ThisIsMe
When I open a Shadowbox dialog from HTA application, accessing to "parent" object fails.
I can workaround this problem by editing the iframe tag in the shadowbox.js as follows:
 before: var S='<iframe id="'+this.id+'"
 after: var S='<iframe application="yes" id="'+this.id+'"

* HTA is a Microsoft-specific web application running locally on Windows.
Loading...