# Comparing selection of a drop down using ajax

**URL:** <https://www.ruby-forum.com/t/comparing-selection-of-a-drop-down-using-ajax/136354>\
**Category:** Rails\
**Created:** [May 1, 2008, 4:46am UTC](https://www.ruby-forum.com/t/comparing-selection-of-a-drop-down-using-ajax/136354 "2008-05-01T04:46:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rushnosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58956e/32.png) [@rushnosh](https://www.ruby-forum.com/u/rushnosh)\
**Post date:** [May 1, 2008, 4:46am UTC](https://www.ruby-forum.com/t/comparing-selection-of-a-drop-down-using-ajax/136354/1 "2008-05-01T04:46:00Z")

</div>

I am very new to ruby and since my javscript skills are zero I was  
wondering if this could be done.

I have a drop down. When the user makes a selection I would like to  
make a call with observe\_field.

Can I then check to see if the selection the user made from the drop  
down menu is in a another array that keep track of what the user has  
selected.

In the array that is checked against will simply add 1 next to the  
item if it is not in the list. That is the user is selecting it for  
the first time.

My English is not very good so I hope this makes sense.

Can someone give me some guidance on this.

---

<div class="post-metadata">

**Author:** ![rushnosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58956e/32.png) [@rushnosh](https://www.ruby-forum.com/u/rushnosh)\
**Post date:** [May 1, 2008, 5:31am UTC](https://www.ruby-forum.com/t/comparing-selection-of-a-drop-down-using-ajax/136354/2 "2008-05-01T05:31:02Z")

</div>

yeah you can get the value of what the select is set at and add it to  
a javascript variable or what not. Google for select javascript.

---

<div class="post-metadata">

**Author:** ![rushnosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58956e/32.png) [@rushnosh](https://www.ruby-forum.com/u/rushnosh)\
**Post date:** [May 1, 2008, 7:30am UTC](https://www.ruby-forum.com/t/comparing-selection-of-a-drop-down-using-ajax/136354/3 "2008-05-01T07:30:17Z")

</div>

So I used \<%= observe\_field :id\_of\_select, url =\> {action =\>  
“add”}, :frequency =\> 0.25 %\>

this is below the select tag when I choose and item from the drop down  
it does absolutely nothing.  
I examined it in firebug and I don’t see anything either.

View of the source shows that it has selected the proper id of the  
drop down.

---

<div class="post-metadata">

**Author:** ![rushnosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58956e/32.png) [@rushnosh](https://www.ruby-forum.com/u/rushnosh)\
**Post date:** [May 1, 2008, 10:16pm UTC](https://www.ruby-forum.com/t/comparing-selection-of-a-drop-down-using-ajax/136354/4 "2008-05-01T22:16:11Z")

</div>

I’m not sure how to do rjs with observe\_field.

---

<div class="post-metadata">

**Author:** ![rushnosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58956e/32.png) [@rushnosh](https://www.ruby-forum.com/u/rushnosh)\
**Post date:** [May 1, 2008, 8:27am UTC](https://www.ruby-forum.com/t/comparing-selection-of-a-drop-down-using-ajax/136354/5 "2008-05-01T08:27:00Z")

</div>

I got something to happen in firebug, but it is calling function 3 or  
4 times while the user goes down the drop down menu.  
Also I can not get it do anything with .js file no out come , tried a  
simple page.insert.

Is observe\_field the correct method?

I have map.connect ‘:controller/:action/:id.:format’  
below it I have a catch all map.connect ‘\*path’, :controller =\>  
‘user’, :action =\> ‘login’
