Created
January 24, 2012 16:22
-
-
Save juanm55/1670943 to your computer and use it in GitHub Desktop.
interesting way of updating text field in rails... without ajax requests....
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= select_tag("objective[indicator_id]", options_for_select([["seleccione indicador",0]] + @indicators.map {|u| [u.name,u.id]}, selected = var_indicator ) , html_options = {:onchange => "this.form.elements['objective[criteria]'].value = this.form.elements['tmp_objective[indicator_id]'].options[ this.form.elements['objective[indicator_id]'].selectedIndex ].text "}) %> | |
<%= text_area_tag "objective[criteria]", var_criteria.to_s , :rows => 5, :cols => 70 %></td> | |
<div style="display:none;VISIBILITY:none;" > | |
<%= collection_select("tmp_objective", "indicator_id" , @indicators, "id", "suggested_criteria", options ={:prompt=>""}) %> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the idea is to select something in the select tag and fill the text area with some info from the DB....
so what is done: select something and have a js that looks up the selection id, in another collection_select (which has the needed information) and find the equivalent id there,,, and put the info into de text_area_tag...
hacky... weird... obstrusive... but works... with no additional actions added to controller, and is vanilla js...