# Retrieving values from combo box

**URL:** <https://www.ruby-forum.com/t/retrieving-values-from-combo-box/119342>\
**Category:** Rails\
**Created:** [November 6, 2007, 8:37am UTC](https://www.ruby-forum.com/t/retrieving-values-from-combo-box/119342 "2007-11-06T08:37:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xenophobicjojo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/c77e96/32.png) [@xenophobicjojo](https://www.ruby-forum.com/u/xenophobicjojo)\
**Post date:** [November 6, 2007, 8:37am UTC](https://www.ruby-forum.com/t/retrieving-values-from-combo-box/119342/1 "2007-11-06T08:37:16Z")

</div>

Jul/10:

 \<%= select\_tag "jul10", "YNR" %\>

At the moment, my html form displays this combo box the way i want it,  
but it does not record down what the user has selected and save it to  
the database

help please,

thanks!

---

<div class="post-metadata">

**Author:** ![xenophobicjojo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/c77e96/32.png) [@xenophobicjojo](https://www.ruby-forum.com/u/xenophobicjojo)\
**Post date:** [November 6, 2007, 12:42pm UTC](https://www.ruby-forum.com/t/retrieving-values-from-combo-box/119342/2 "2007-11-06T12:42:33Z")

</div>

Are you generating your form using form\_for :foo ?, if so then you’d  
want  
something like this:

\<%= foo.select\_tag :jul10, %w( Y N R ) %\>

Assuming jul10 is a member of the object you’re saving into (using  
update\_attributes, or new(params[:foobar])).  
Does this help, if not, what does your controller method look like that  
is  
saving the record?

Cheers,  
James

---

<div class="post-metadata">

**Author:** ![xenophobicjojo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/c77e96/32.png) [@xenophobicjojo](https://www.ruby-forum.com/u/xenophobicjojo)\
**Post date:** [November 9, 2007, 4:15am UTC](https://www.ruby-forum.com/t/retrieving-values-from-combo-box/119342/3 "2007-11-09T04:15:10Z")

</div>

erm…i’m new to ruby =( don’t really understand what you said, so  
sorry

but i’m not generating my form, i created this form myself  
and replaced it in the \_form.rhtml

Jul/10:

 \<%= select\_tag "jul10", "YNR" %\>

produces the combo box but doesn’t actually save the value into my  
database when the user clicks create, everything else that the user  
types in other fields can be saved though.

below is the whole \_form.rhtml

\<%= error\_messages\_for 'course' %\>

...

…

| 
### Course Details:

### 
 |
| 
### Presentation Details:
 |
| 

Final Presentation (mmm yyyy):

 | \<%= text\_field "course", "final\_presentation", :size=\>"5" %\> | 

Presentation Pattern:

 | \<%= text\_field "course", "presentation\_pattern", :size=\>"30" %\> |
| 

Jan/08:

 | \<%= select\_tag "jan08", "YNR" %\> | 

Jul/08:

 | \<%= select\_tag "jul08", "YNR" %\> |

thanks!
