Paulo C. wrote:
Hello
I have a view which have 2 radio buttons :
…
Actuel |
<%= radio_button_tag(:actuel, value = "1", checked
= false, options = {}) %>
|
Last |
<%= radio_button_tag(:last, value = "1", checked =
false, options = {}) %> |
...
I dont know how to proceed to control the status of my radio buttons.
When I click on the first one, i want to put the 2nd unchecked. When I
click on the 2nd one I want to uncheck the first one.
I know how to to it using html radio buttons + javascript. But using
radio_button_tag I dont know how to proceed.
Anyone can help me please?
thanks
regards
I had put the radio buttons with the same name to be on the same group.
actuel |
<%= radio_button_tag(:type_recherche, value = "1",
checked = false, options = {}) %>
| last |
<%= radio_button_tag(:type_recherche, value = "2",
checked = false, options = {}) %> |
To pass the values I use a link_to_remote:
<%= link_to_remote “Rechercher”,
:update => “resultlist”,
:url => { :action => ‘rechercher’},
:with => “…+ ‘&’ +
‘type_recherche=’ + $F(‘type_recherche’)”,
:complete => visual_effect(:appear, ‘resultlist’, :duration => 1.00)
%>
In my controller when i try to access to the “type_recherche” value (my
2 radio buttons), I do this:
if params[:type_recherche].nil?
puts “1”
@demand.type_recherche = “0”
else
if params[:type_recherche].to_s == ‘null’
@demand.type_recherche = “0”
else
puts "6 -> " + params[:type_recherche].to_s
@demand.type_recherche = params[:type_recherche]
end
end
When i check the first radio it works fine. I receive the value “1”. But
when i check the second radio button, i always receive null. It seems
that the only radio button used is the first one.
Any idea about this problem.
Thanks