Observe_field and select lists

I’m somewhat confused on how to set up a select list for observe_field. Example :

I want ot get the values when the user chooses them from the list. The "search[state_id] is not important as it’s from a regular search form. Just not sure how to name or id these lists so I can set up the observe_field. Does my question make sense ?

Reading through some observe_field examples I’ve seen for a text_field it’s something like this :

<%= text_field_tag("query", @params['query'], :size => 10 ) %>

Selects are the same ? (And yeah I should try it anyway before asking :slight_smile:

Stuart

<select name="search[state_id]" size="10" multiple="multiple" id='someid'>

then observe field on 'someid'

-Ezra

So it looks like there is no <%= %> erb ? tags surrounding the select ?

Is that correct ?

Stuart

I'm not sure if we are talking about the same thing here. I was just saying that there is no id tag on your select tag so the observe fielkd has no dom id to observe. You don't have to use helpers to make the select but you do need an id on the select tag. Here ia a working example that I am using. I like to write out the form observer JS by hand though as it is more flexible:

<%= select_tag 'snapshot[version]',               options_for_select( @snapshot.versions.map{|v| v.version}, @selected_snapshot.version),               :id => 'snapshot_select'%>

  <script type="text/javascript">     //<![CDATA[       new Form.Element.EventObserver("snapshot_select", function(element, value) {         new Ajax.Request('/apps/snapshot_version/<%= @app.id -%>', {asynchronous:'true', evalScripts:'true', parameters:'version=' + value})       })     //]]>   </script>

-Ezra

No we are talking about the same thing. Thanks for your help. Clears up at least one piece of the puzzle. Stuart