Topic: I want to change capcha if the user clicks the "change image" link

Hi,
   What can we write in rjs templates.
   Is it possible to refresh a div or reload a div.
   what code can be written in .rjs ? Whatever that can be write in .rhtml
   can also be written in .rjs as well?
       
   I'm using validates_capcha plugin and turned on validates_capcha in model User.
   I want to change image whenever the user clicks on "change image" link. Plz help me in
   this regard.




testrjs.rhtml
-----------------------------------------------
<div id=message>

          dddddddddddddd
  </div>

<div id=target>
<% c = prepare_captcha :type => :image -%>
  <%= captcha_hidden_field c, 'user' %>
  <%= captcha_image_tag c %> <br>
  <%= captcha_label 'user', 'Type in the text from the image above' %> <br>
  <%= captcha_text_field 'user' %>
</div>

    <%= link_to_remote("change image",
          :url =>{ :action => :add }
           ) %>



# action and controller - user controller action is add
-----------------------------------------------
def add

end



add.rjs
---------------------------------------
page.visual_effect :highlight, '', :duration => 3
page.insert_html 'target',
                  :reload

Re: I want to change capcha if the user clicks the "change image" link

#outer HTML (including the div)
page.replace_html 'div_id', :partial => 'person', :object => @person
#inner HTML
page.replace_html 'div_id', :partial => 'person', :object => @person

You may want to check out:
http://www.rubyonrails.org/api/classes/ … thods.html