# Submit form in popup and send value back to the main page

**URL:** <https://www.ruby-forum.com/t/submit-form-in-popup-and-send-value-back-to-the-main-page/185621>\
**Category:** Rails\
**Created:** [March 23, 2010, 6:08pm UTC](https://www.ruby-forum.com/t/submit-form-in-popup-and-send-value-back-to-the-main-page/185621 "2010-03-23T18:08:16Z")\
**Posts on this page:** 2\
**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:** [March 23, 2010, 6:08pm UTC](https://www.ruby-forum.com/t/submit-form-in-popup-and-send-value-back-to-the-main-page/185621/1 "2010-03-23T18:08:16Z")

</div>

I made a popup within object1’s form to show another form to create a  
new document object to associate with object1. When I click the  
submit button I want

1. the document object to be created
2. the popup to close
3. the value in the document “title” field to get added to the  
document name field in object1’s form.

I’ve made the form for the document object in the popup but I’m having  
trouble figuring out the logic for 2) and 3). I’d imagine I have to  
use javascript to close the popup and send the title back to the main  
page.

---

<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:** [March 23, 2010, 7:22pm UTC](https://www.ruby-forum.com/t/submit-form-in-popup-and-send-value-back-to-the-main-page/185621/2 "2010-03-23T19:22:38Z")

</div>

I added some javascript to the create.html.erb template that opens in  
the popup after the document form submits.  
The javascript is supposed to close the popup and send the title of  
the document back to the main page but it’s not working. Anyone know  
why?

this is what is in the create.html.erb template:
