Sending DIV form content when submitting form

Hi All

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

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
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


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 ={|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.

    This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

    | Privacy Policy | Terms of Service | Remote Ruby Jobs