views:

200

answers:

1

I have a list of options generated by the following Haml code.

  %select#tags{:onchange => remote_function(:url => {:action => :display_tag_cart}, :with  => 'Form.Element.serialize(this)'), :prompt => 'Choose a Tag'}
    %option{:value=>""}
      Choose a Tag
    -Tag::TAGS.each do |t|
      %option{:value=>t.id}
        =h t.name

Form.Element.serialize(this) does not work.

How do I pass the value of the selection to display_tag_cart?

A: 

what about this.options[this.selectedIndex].value

Try

 %select#tags{:onchange => remote_function(:url => {:action => :display_tag_cart}, :with  => 'this.options[this.selectedIndex].value'), :prompt => 'Choose a Tag'}
    %option{:value=>""}
      Choose a Tag
    -Tag::TAGS.each do |t|
      %option{:value=>t.id}
        =h t.name
Salil