# Populate a combo box

**URL:** <https://www.ruby-forum.com/t/populate-a-combo-box/177113>\
**Category:** Rails\
**Created:** [October 11, 2009, 11:47pm UTC](https://www.ruby-forum.com/t/populate-a-combo-box/177113 "2009-10-11T23:47:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![spitfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@spitfire](https://www.ruby-forum.com/u/spitfire)\
**Post date:** [October 11, 2009, 11:47pm UTC](https://www.ruby-forum.com/t/populate-a-combo-box/177113/1 "2009-10-11T23:47:59Z")

</div>

Hi,  
I am struggling with this problem: in a page there are 2 combo box:  
category and subcategory. When I select a category the subcategory combo  
must update its values.

I would like to use JQuery with Ajax to load subcategory after category  
change.

It important the page works also without Javascript, Do you have some  
idea to accomplish that ?

thank you !  
Alessandro

---

<div class="post-metadata">

**Author:** ![spitfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@spitfire](https://www.ruby-forum.com/u/spitfire)\
**Post date:** [October 12, 2009, 12:00am UTC](https://www.ruby-forum.com/t/populate-a-combo-box/177113/2 "2009-10-12T00:00:16Z")

</div>

Ale Ds wrote:

> Hi,  
> I am struggling with this problem: in a page there are 2 combo box:  
> category and subcategory. When I select a category the subcategory combo  
> must update its values.

I’m assuming you mean list boxes here. Comboboxes are slightly  
different.

> I would like to use JQuery with Ajax to load subcategory after category  
> change.

observe\_field should do it.

> It important the page works also without Javascript, Do you have some  
> idea to accomplish that ?

Yes. You’ll need to submit the form after the category is chosen if  
you’re doing without JS. There’s no other way.

> thank you !  
> Alessandro

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![spitfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@spitfire](https://www.ruby-forum.com/u/spitfire)\
**Post date:** [October 13, 2009, 12:42am UTC](https://www.ruby-forum.com/t/populate-a-combo-box/177113/3 "2009-10-13T00:42:55Z")

</div>

> > I would like to use JQuery with Ajax to load subcategory after category  
> > change.
> 
> observe\_field should do it.

I know that observe\_field is a PrototypeHelper methods,  
I am using Jquery, then is it better to use only JQuery methods ?

Bye,  
Alessandro
