# Id of new object dynamically created in a nested form

**URL:** <https://www.ruby-forum.com/t/id-of-new-object-dynamically-created-in-a-nested-form/187611>\
**Category:** Rails\
**Created:** [April 26, 2010, 8:10pm UTC](https://www.ruby-forum.com/t/id-of-new-object-dynamically-created-in-a-nested-form/187611 "2010-04-26T20:10:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ESESES](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f0a364/32.png) [@ESESES](https://www.ruby-forum.com/u/ESESES)\
**Post date:** [April 26, 2010, 8:10pm UTC](https://www.ruby-forum.com/t/id-of-new-object-dynamically-created-in-a-nested-form/187611/1 "2010-04-26T20:10:37Z")

</div>

In my nested form I have a link to open a popup with selections. When  
a selection is made, the popup closes and the selection is added to a  
text box.

Because I have objects that can be dynamically created in the form I  
can’t just use the id of the object to assign the selection to the  
input text box.

I have this in my view

 \<%= f.text\_field :couchetype, :readonly=\>true%\> \<%= link\_to( image\_tag('more.png', :border=\>0, :id=\>"sample\_sample"), {:controller=\>"thesaurus", :action=\>"list"}, { :popup=\>['thesaurus', 'height=800,width=400,location=no,scrollbars=yes']}) %\> 

and then this in the popup

function copyData(id,value){  
var el = window.opener.document.getElementById(id);  
if (!el.value)  
el.value = value;  
else  
el.value = el.value + "; " + value;  
this.close();  
}

I want to send the id of the new object to the popup so that I can  
refind the text box to assign the selections. How can I do that?
