Forum: Ruby on Rails Clearing text_field_tag -- Help PLEASE

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bill W. (Guest)
on 2006-04-20 19:51
(Received via mailing list)
I'm trying to clear the input fields on an Ajax form.  Unfortunately,
I've tried this just about every way I can
think of and instead of clearing the fields, it's clearing pretty much
the whole page.  I would ***really*** appreciate some help!

The page has a form that allows the entry of two fields.  The form
exists inside a <div> with id=entry.  When the user clicks the button, a
new line is added to the page inside a <div> with id=ingredient_list.
The user can add as many lines as they want.  I want to clear the fields
each time they click the button. What's happening instead is that the
entry <div> and everything above it on the page is getting wiped out.
The code is below.  Any ideas?

Thanks in advance,

--- Here's _entry_form.rhtml ---
<%= form_remote_tag(:update => 'ingredient_list',
          :url => {:action => :add_ingredient},
          :position => 'bottom',
          :after => {:action => :clear_entry}) %>
   <%= text_field_tag :name %>
   <%= text_field_tag :qty %>
   <%= submit_tag 'Add Ingredient' %>
<%= end_form_tag %>

--- and here's the clear_entry action in the controller ----
def clear_entry
   render :update do |page| = ''
      page.entry.qty.value = ''
This topic is locked and can not be replied to.