RJS replace adding multiple inputs



I have a classic problem. I want to replace a hidden field inside a
form with a hidden field with some value when a link_to_remote is
pressed. In the link’s action rjs, I’m doing the following:

Assume my form has the following field already

<%= hidden_field(‘client’, ‘company_id’) $>

So I have a bunch of companies in a list with link_to_remote tags to
action select_company.rjs inside which I want:

page.replace “client_company_id”, hidden_field(“client”, “company_id”, :
value => @company.id

But when I do this, it works but it adds an additional blank

Anyone know why?