I am using Ruby on Rails 3 and I would like to retrieve a value from a form text field and set that value in another form text field using RJS as the following (or in a better way!):
update_page_tag do |page|
page.event.observe('text_field1_css_id', 'keyup') do |element|
element << ... # Get and set a '@variable' value using the value in the
# HTML textarea tag with id = 'text_field1_css_id'. The
# '@variable' value should be accessible from the
# 'element.replace_html' method stated below
element << ...
...
element.replace_html (:text_field2_css_id), @variable.inspect
end
end
How can I do that using the Prototype framework?
In prototype:
For others who might be interested, if you’re using jquery, you can probably use: