On change of drop down showing a new textfield


i have a situation where i have a list of options from which a user
his options if its not in the list he/she selects Others/Not Present and
new textfield should pop up and the data entered there should be
instead of dropdown.

i have done this using javascript/dhtml but i was wondering how this can
done using pure rails i.e using some of the RoR apis?.

i would appreciate if anyone helps me with this.

warm regards
gaurav v bagga


Observe field is really good for this. If you set an observe field on
select box, and leave out the frequency option it will perform the
action on
onchange. I think there is also an :on option that you can specify the

It then becomes an rjs response (or inline render of the page object) to
supply the text box with value etc.

Hope this is what your after

thanks for your reply ,
but i have started RoR a week back and i am really new, what you said i
didn’t get,
well i will google around what you have said and try to find out the way


Something like this…

<%= observe_field(‘tournament_id’, :update => ‘event_select’, :url =>
{:action => ‘tournament_select’}) -%>

Then just be sure you have a tournament_select method in your controller
and that div will get updated with it’s content.


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