Hi!
How can i use ajax with radio buttons?
I have form with 2 radio buttons, which updates div with the value of
selected radio button. It worked correctly when i used submit button,
but when i removed it and used observers it didn’t. When i press the
first button it displays its value, but when i press the second button
it displays new value for a moment (0.5s ?) and then suddenly changes to
the first value.
Is there a way to send values just on ‘onclick’ or ‘onchange’ events?
Here’s my observer:
<%= observe_field(“user_osoba”, :frequency => 0.5,
:update => “new_user_form”, :url => { :action => ‘select_type’,
:type => ‘person’ }) %>
and here’s ‘select_type’ action:
def select_type
@type = params[:type] || ‘’
if @type == ‘person’
render :text => @type
elsif @type == ‘company’
render :text => @type
end
end