# Observe\_field and select lists

**URL:** <https://www.ruby-forum.com/t/observe-field-and-select-lists/71765>\
**Category:** Rails\
**Created:** [October 11, 2006, 11:52am UTC](https://www.ruby-forum.com/t/observe-field-and-select-lists/71765 "2006-10-11T11:52:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 11, 2006, 11:52am UTC](https://www.ruby-forum.com/t/observe-field-and-select-lists/71765/1 "2006-10-11T11:52:33Z")

</div>

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

\<%=options\_from\_collection\_for\_select @states, :id, :name %\>

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 🙂

Stuart

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 11, 2006, 7:38pm UTC](https://www.ruby-forum.com/t/observe-field-and-select-lists/71765/2 "2006-10-11T19:38:04Z")

</div>

On Oct 11, 2006, at 2:44 AM, Dark A. wrote:

> 

then observe field on ‘someid’

-Ezra

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 11, 2006, 8:24pm UTC](https://www.ruby-forum.com/t/observe-field-and-select-lists/71765/3 "2006-10-11T20:24:32Z")

</div>

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

Is that correct ?

Stuart

On 10/11/06, Ezra Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> then observe field on ‘someid’
> 
> -Ezra
> 
> >

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 12, 2006, 12:56am UTC](https://www.ruby-forum.com/t/observe-field-and-select-lists/71765/4 "2006-10-12T00:56:26Z")

</div>

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

On 10/11/06, Ezra Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Stuart
> 
> fielkd has no dom id to observe. You don’t have to use helpers to
> 
> -Ezra
> 
> >

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 11, 2006, 10:12pm UTC](https://www.ruby-forum.com/t/observe-field-and-select-lists/71765/5 "2006-10-11T22:12:46Z")

</div>

On Oct 11, 2006, at 11:01 AM, Dark A. wrote:

> 

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})  
})  
//]]\>

-Ezra
