# Sending DIV form content when submitting form

**URL:** <https://www.ruby-forum.com/t/sending-div-form-content-when-submitting-form/133221>\
**Category:** Rails\
**Created:** [March 28, 2008, 11:15pm UTC](https://www.ruby-forum.com/t/sending-div-form-content-when-submitting-form/133221 "2008-03-28T23:15:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dekhaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c37758/32.png) [@dekhaus](https://www.ruby-forum.com/u/dekhaus)\
**Post date:** [March 28, 2008, 11:15pm UTC](https://www.ruby-forum.com/t/sending-div-form-content-when-submitting-form/133221/1 "2008-03-28T23:15:42Z")

</div>

Hi All

```
   I have a form that has two select/list form elements. I'm

```

using  
ajax (rjs, partials, and observe\_field) to enable a user to move items  
from one list/select to another list/select. When the user is  
satisfied  
with the items they’ve collected in the ‘destination’ list/select  
box, they hit a ‘Submit’ button.

```
  My question is how do I pass along the contents dynamically

```

added to the ‘destination list/select’ box along with the Submit  
request - without the user having to select items in the ‘destination  
list/select’ box. The items the user ‘wants’ have already been  
selected by being put in this ‘destination list/select’ box - so they  
shouldn’t have to select them again.

```
   Any help is greatly appreciated

```

Thanks  
Dave

---

<div class="post-metadata">

**Author:** ![dekhaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c37758/32.png) [@dekhaus](https://www.ruby-forum.com/u/dekhaus)\
**Post date:** [March 31, 2008, 6:36pm UTC](https://www.ruby-forum.com/t/sending-div-form-content-when-submitting-form/133221/2 "2008-03-31T18:36:15Z")

</div>

Let’s say the div now looks like:

- ...
- ...
- ...

Use Prototype to collect the id’s of your destinations into an array.  
Then, but that into a hidden field in your form:  
“$(‘hidden\_field\_id’).value = destinations\_array.join(’,’)”

Then, in your controller, you can:  
destination\_ids = params[:…][:hidden\_field\_id].split(’,’)  
destinations = destination\_ids.map{|d\_id| Destination.find(d\_id) }  
#or use something like: Destination.find(:all, :conditions=\>[‘id in ?’,  
destination\_ids ]  
#but be sure to sterilize it

Hopefully that provides a starting point for you.  
Mike
