# Problems with RJS

**URL:** <https://www.ruby-forum.com/t/problems-with-rjs/104217>\
**Category:** Rails\
**Created:** [May 15, 2007, 3:41pm UTC](https://www.ruby-forum.com/t/problems-with-rjs/104217 "2007-05-15T15:41:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![patcito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/50afbb/32.png) [@patcito](https://www.ruby-forum.com/u/patcito)\
**Post date:** [May 15, 2007, 3:41pm UTC](https://www.ruby-forum.com/t/problems-with-rjs/104217/1 "2007-05-15T15:41:05Z")

</div>

Hey all,  
I’m trying to replace a select with text\_field by clicking on a  
link\_to\_remote with RJS. This part work, but then when I try to  
replace the text\_field back by the select tag it doesn’t work in  
firefox (it does work in IE and Safari though).

Here is the code in my view:

Production:

\<%= select\_tag 'production','' %\> \<%= link\_to\_remote 'add another production',:url=\>{:action=\>'addtextfields',:type=\>'production'} %\>

and here is the code in my controller (one function to replace the  
select by a textfield and another one to repoace the textfield by a  
select):

def addtextfields  
render :update do |page|  
page[params[:type]].replace\_html  
text\_field\_tag(params[:type])+link\_to\_remote(’  
cancel’,:url=\>{:action=\>‘canceltextfield’,:type=\>params[:type]})

end  
end

```
def canceltextfield
  @type=params[:type]
  @collection=User.find :all
  render :update do |page|

```

page[params[:type]].replace\_html  
select\_tag(params[:type],@collection.collect {|c| [c.login, c.id]  
})+link\_to\_remote(‘add another  
production’,:url=\>{:action=\>‘addtextfields’,:type=\>params[:type]})  
end  
end

Any idea what’s wrong?

Thanx in advance

Pat
