Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
how to get value from select box in partials
2 Posts
how to get value from select box in partials

I didn't realize that the form would work like this either - but maybe it needs some special massaging to add new input elements to it once it has been rendered the first time. My solution to this would be to change your @to_be_updated@ div so that it includes the partial in the initial view, the form will then be aware of that select element, and changes to it will just cause the new values to be sent with the form. So line 11 of your view pastie would look like this:

bq. <div id='to_be_updated'> 'input_field' %></div>

And obviously you'd also need to set the @@servicesubentities@ instance variable in your action that renders that form. I'd have to test before being sure, but probably you can just set it to @[]@.

Hi Expert,

I am totally vexed with this, please anyone help me.... Thanks in advance..

My problem is:

I want to dynamically populate 2nd select box based on 1st select box. I used "observe_field" for 1st select box and action to def in controller. I can explain clearly with my code.

index.html.erb ........................................................

http://pastie.org/434678

........................................................ Here is my controller, logic to get values from database corresponding to selection

http://pastie.org/434679

My select box in partial is changing dynamically, but problem is the data selected in 2nd select box (which is in partial) is not available, because it is out of form… Please anyone give me a suggestion how to get the selected data in partial…. Pleaseeeee :(

2 Posts
Login to add your message