Thank you for reply. It really helped! Thanks again :)
On 7월27일, 오전4시05분, bill walton <[email protected]> wrote: > Hi serenobs, > > On Sun, 2009-07-26 at 11:35 -0700, serenobs wrote: > > Hi. > > > I used radio_button_tag. > > and I want to pass the value of selected radio button to controller. > > > <%= radio_button_tag 'exp', 1 %> > > <%= radio_button_tag 'exp', 2 %> > > > <%= link_to :action=>"do" %> > > can i pass the radio button's value to above method as a parameter? > > You can using link_to_remote, which generates an Ajax request. > > <div id="radio_buttons"> > <%= radio_button_tag 'exp', 1 %> > <%= radio_button_tag 'exp', 2 %> > </div> > > <%= link_to_remote 'Submit now', :url => {:action=>"do"}, :submit => > 'radio_buttons' %> > > The selected radio button's value will be accessable in your controller > method via the name you've given your radio buttons. So in this case, > the 'do' method in your controller would probably look something like: > > def do > > if params[:exp] = '1' #remember that params come back as strings > do_something > elsif params[:exp] = '2' > do_something_else > else > handle_the_no_default_radio_button_case # if you want one to be checked, > supply true as the third parameter > end > > respond_to do |format| > format.js { > render :update do |page| > page.replace_html or some other reponse > end > } > end > end > > HTH, > Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

