Getting the value of a text area

I have a form where the user will type in some text in a text area.
When
this form gets submitted, all of the info gets pushed into a MySQL
table.

The text area in question can have HTML and special formatting. I want
to
create a preview div for this.

I can use observe_field to preview the formatting as they type, but I’d
rather have it set so that they can click a “Preview” link and AJAX will
update the DIV after formatting the info in the text area.

My question is this: how do I get the information in the text_area to
the
AJAX action called by my preview link?

  • David

Hi David,

David R. wrote:

My question is this: how do I get the information
in the text_area to the AJAX action called by my
preview link?

If you’re using observe_field you can use the :with option to pass the
value
in a named param. For example,

<%= observe_field(id_of_field_to_watch, :url =>{:action =>
‘update_action’,
:id => ‘div_to_update’}, :with => ‘content’ ) %>

will make the content of the field being observed available in the
‘update_action’ action in the controller via params[:content]

hth,
Bill