<%= select_tag “content_type”, options_for_select(content_type_options),
{ :onchange =>
remote_function(
:url => {:action => ’filter_by_content’},
:with => ‘Form.Element.serialize(this)’) } %>
The above code allows to submit via javascript the selected value of a combo box. The remote call is triggered via the onchange event handler of the select tag. Notice the parameters to the remote function call :url, as usual, but also the :with parameter. The :with option can be very useful if you need more control on what data needs to be sent to the server. In this case we use Form.Element.serialize that url encodes all the parameters found in a given div (doesn’t need to be a form). In this case the content_type=snippet is passed to the server.