# Beginner question about a combo box

**URL:** <https://www.ruby-forum.com/t/beginner-question-about-a-combo-box/71727>\
**Category:** Rails\
**Created:** [October 11, 2006, 3:41am UTC](https://www.ruby-forum.com/t/beginner-question-about-a-combo-box/71727 "2006-10-11T03:41:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsn1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@jsn1](https://www.ruby-forum.com/u/jsn1)\
**Post date:** [October 11, 2006, 3:41am UTC](https://www.ruby-forum.com/t/beginner-question-about-a-combo-box/71727/1 "2006-10-11T03:41:17Z")

</div>

Hi all

I want to translate this HTML code into a RoR code. The form is very  
simple, it has a combo box, and when the user selects a value in the  
list I would like to display a message that says, “You selected the  
color X”

I know that I need a controller and a viewer. My question is about what  
do I need to code the viewer to do somethin similar to this:

Select A Color From The List: Red Green Blue Pink Yellow 

thanks

---

<div class="post-metadata">

**Author:** ![jsn1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@jsn1](https://www.ruby-forum.com/u/jsn1)\
**Post date:** [October 11, 2006, 6:59am UTC](https://www.ruby-forum.com/t/beginner-question-about-a-combo-box/71727/2 "2006-10-11T06:59:46Z")

</div>

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

> ```
> <option value="Red">Red</option>
> <option value="Green">Green</option>
> <option value="Blue">Blue</option>
> <option value="Pink">Pink</option>
> <option value="Yellow">Yellow</option>
> 
> ```

You can do something like this:  
  
…

If you want to run some action on change, then write like this:  
\<select name=‘select’ onchange=‘\<%= remote\_function :url =\> { :action =\>  
‘changed’ }, :with =\> “Form.Element.serialize(this)” %\>’\>  
…

---

<div class="post-metadata">

**Author:** ![jsn1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@jsn1](https://www.ruby-forum.com/u/jsn1)\
**Post date:** [October 14, 2006, 2:16pm UTC](https://www.ruby-forum.com/t/beginner-question-about-a-combo-box/71727/3 "2006-10-14T14:16:58Z")

</div>

Maxim,

here is what I wrote in ROR and it works  
html\>

 Combo Box!!! \<%= start\_form\_tag :controller=\>'color', :action=\>'hi' %\> 

Select a color: \<%=select\_tag "textTag", options\_for\_select(%w{ Red Green Blue Pink Yelow }) %\>

\<%= @message %\>

\<%= submit\_tag( "Submit") %\>

\<%= end\_form\_tag %\>

thanks

Kulkin wrote:

> On 10/11/06, Jose P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > ```
> > <option value="Red">Red</option>
> > <option value="Green">Green</option>
> > <option value="Blue">Blue</option>
> > <option value="Pink">Pink</option>
> > <option value="Yellow">Yellow</option>
> > 
> > ```
> 
> You can do something like this:  
>   
> …
> 
> If you want to run some action on change, then write like this:  
> \<select name=‘select’ onchange=‘\<%= remote\_function :url =\> { :action =\>  
> ‘changed’ }, :with =\> “Form.Element.serialize(this)” %\>’\>  
> …
