Ruby on Rails Saturday, October 18, 2014

On Oct 15, 2014, at 5:58 PM, Esteban Penagos <lists@ruby-forum.com> wrote:

> hi colin
> my problem is: I need to capture the value of <% = select_tag "list",
> options_for_select (["0", "10", "15"], "0")%>
> in a variable, to calculate the value of the product
>
> conclucion the user chooses in the 0 or 10 or 15 and I need to capture
> that number as a variable
>
> thank you very much
>

You would "capture" that value in your controller when you handle the form submitted by the user, so in your #create or #update methods. Whatever that form field is named will be submitted in the params hash, with the value set to their choice.

If you are talking about capturing the setting before they submit the form, then you are into the realm of JavaScript, and in Rails this is usually handled in an unobtrusive JS handler. Read up on Ajax and Rails for more details about that.

Walter

> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c2570f14b4cf87093988ee02b010c085%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9C568138-57A7-4860-877C-8A6CC03A1CCF%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment