# AJAX, checkbox array

**URL:** <https://www.ruby-forum.com/t/ajax-checkbox-array/81825>\
**Category:** Rails\
**Created:** [January 15, 2007, 2:54pm UTC](https://www.ruby-forum.com/t/ajax-checkbox-array/81825 "2007-01-15T14:54:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![F.BSten\_Kate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/85e7bf/32.png) [@F.BSten\_Kate](https://www.ruby-forum.com/u/F.BSten_Kate)\
**Post date:** [January 15, 2007, 2:54pm UTC](https://www.ruby-forum.com/t/ajax-checkbox-array/81825/1 "2007-01-15T14:54:04Z")

</div>

Owkay i currently have a list of checkboxes called: option\_ids[], this  
will give me a nice array of the options selected. How ever… every  
time the user chnages their options an ajax request should be made, as  
follows:

\<%= observe\_field(“option\_ids[]”,  
:frequency =\> 0.25,  
:update =\> “infoprijs”,  
:url =\> { :action =\> :getprijs },  
:with =\> “formdata = Form.serialize(‘bestel’)”) %\>

---

<div class="post-metadata">

**Author:** ![F.BSten\_Kate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/85e7bf/32.png) [@F.BSten\_Kate](https://www.ruby-forum.com/u/F.BSten_Kate)\
**Post date:** [January 15, 2007, 2:56pm UTC](https://www.ruby-forum.com/t/ajax-checkbox-array/81825/2 "2007-01-15T14:56:11Z")

</div>

Owkay, it submited while i wasnt done typing yet… My bad 🙂

Problem with the code above is that it only handles the ajax request  
when the FIRST checkbox is changed, this because all the check boxes  
have the same name/id… Is there any way to fix this without making the  
same amount of ajax statements as there are checkboxes, cause i’d think  
thats a very unefficient solution.

---

<div class="post-metadata">

**Author:** ![F.BSten\_Kate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/85e7bf/32.png) [@F.BSten\_Kate](https://www.ruby-forum.com/u/F.BSten_Kate)\
**Post date:** [January 7, 2008, 6:36am UTC](https://www.ruby-forum.com/t/ajax-checkbox-array/81825/3 "2008-01-07T06:36:27Z")

</div>

F. B., did you ever figure this one out? I have the same need

F.B. ten Kate wrote:

> Owkay, it submited while i wasnt done typing yet… My bad 🙂
> 
> Problem with the code above is that it only handles the ajax request  
> when the FIRST checkbox is changed, this because all the check boxes  
> have the same name/id… Is there any way to fix this without making the  
> same amount of ajax statements as there are checkboxes, cause i’d think  
> thats a very unefficient solution.
