[Zope] returning a selected object

Casey Duncan cduncan@kaivo.com
Fri, 13 Apr 2001 13:28:07 -0600


> Tom Deprez wrote:
> 
> Hi,
> 
> Does anybody knows how to open a popup window, let the user choose
> something out of a list and return this value
> back to the form which opened the popup window?
> 
> Thanks in advance,
> 
> Tom.

This is done using javascript:

Calling (parent) page code:

<script type="text/javascript">
<!--
    function popUpWindow(url) {
        w = window.open(url, 'popup',
"left=30,top=30,width=550,height=470,menubar,toolbar,scrollbars,status,location");
        w.focus();
    }
//-->
</script>

<form name="parent_form">
   <input type="text" name="parent_field" />
   <input type="button" onclick="popUpWindow('<Pop up page URL>')"
value=" Select " />
</form>

Pop up page:

<script type="text/javascript">
<!--
    function returnSelection(list) {
        opener.document.parent_form.parent_field.value =
list[list.selectedIndex].value;
        window.close();
    }
//-->
</script>

<form>
    <select name="list" size="10">
        <Put your options here>
    </select>
    <input type="button" onclick="returnSelection(this.form.list)"
value=" OK " />
</form>

hth,
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>