Pass selected value in combo as a parameter

Hi,

I have a select in my form:

<%= select @issue_type, “name”, @issue_types.collect {|p| [p.name,
p.id]} %>

What I need to do is execute a method passing the value selected in the
combo. I’ve tried lot of things, but I couldn’t.

@issue_type is created in the controller and I assigned the first value
in the collection. Of course, this is the value I only can pass.

To retrieve the value in the combo I’ve tried with onchange, but… I
couldn’t make it work

Thanks in advance

Again answering to myself…

I solved the problem by:

1-Using link_to_remote using :with clause, and passing as serialize
the id of the div that I had to create sourranding the select
2-In the controller, once taked the parm and maked all the operations,
use respond_to js and reloading the page.

Probably not the best solution… but it works!

What I usually do is get things working without Ajax first. Assuming
you’ve done that, does onchange trigger anything in the logs? Using
firebug or the developer tools in chrome/safari could tell you a lot
too.

Luke

On 3 September 2010 11:35, Alfredo B. [email protected] wrote:

Hi,

I have a select in my form:

<%= select @issue_type, “name”, @issue_types.collect {|p| [p.name,
p.id]} %>

What I need to do is execute a method passing the value selected in the
combo. I’ve tried lot of things, but I couldn’t.

Where are you trying to execute the method? In the browser or in the
server? If in the browser then you will have to use javascript (in
which case it is not really a Rails question), if in the server then
put the select in a form and the selected value will be passed in
params when the form is submitted.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs