observer with group of radio buttons


My code looks like this
      <input type="radio" id="criteria[<%=count%>][date_range]"
name="criteria[<%=count%>][date_range]" value="<%=arr[0]%>" />

<%= observe_field("criteria[#{count}][date_range]",
                    :url => { :action => :date_range, :count =>
count,:type_id => type_id, :report_key => report_key },
                     :frequency => 3,
                    :with => "'type_id='+value") %>
I have a group of radio buttons and i want the observer to fire an
action when any radio button is checked.
But the observer is not working. Can someone suggest what could be the
possible reason for it not to work.


Well you seem to have a loop which generates multiple buttons all
apparently with the same id (which should be unique), then you set up
one observer after the loop.

But if i have a group of radio buttons, they should have the same id
so that they form a group
Also if i give them different ids then on what will my observer field

No it's the name which groups the buttons:

Dom ids should be unique, or it's quite likely that the browser will
get confused at best.

I think that you either need an observer for each button, or if they
are in a form you can use observe_form which will trigger when any
element in the form changes.

If i give them all different ids, then will it be possible to have a
observe_field on the name of the radio buttons
as the number of buttons is quite high and i dont want to have a
separate observer for each button as that will make the code quite
And my form is being built up dynamically so i cant have observe_form