Inserted html using javascript function

I'm using a javascript function to insert html code into my page (following the Railscast on nested models)

The function that inserts the javascript is this:

function add_result(link, association, content) {

  var new_id = new Date().getTime();   var regexp = new RegExp("new_" + association, "g");   var linkrow = $(link).up("tr");

  linkrow.insert({     after: content.replace(regexp, new_id) }); }

And this is the html.erb that is inserted:

  <% for c in @picture_fields %>

    <% if c == "intervention" %>       <tr class="pictureclass">       <td class="name"><%=t 'form.results.picture.'+c%></td>       <td><%= f.radio_button c, t('form.results.picture.interventionoptions.option1')%><%=t 'form.results.picture.interventionoptions.option1'%><%= f.radio_button c, t('form.results.picture.interventionoptions.option2')%><%=t 'form.results.picture.interventionoptions.option2'%><%= f.radio_button c, t('form.results.picture.interventionoptions.option3')%><%=t 'form.results.picture.interventionoptions.option3'%></td>       <td></td>       </tr>

     <% elsif c == "couchetype" %>       <tr class="pictureclass">       <td class="name"><%=t 'form.results.picture.'+c%></td>       <td><%= f.text_field :selected_couchetypes, :readonly=>true %></

      <td class="more"><%= link_to( image_tag('more.png', :border=>0, :id=>"new_results_pictures_results_pictures_couchetype"), {:controller=>"thesaurus", :action=>"list", :id=>"new_results_pictures_results_pictures_couchetype"}, { :popup=>['thesaurus', 'height=800,width=750,location=no,scrollbars=yes']}) %>      </td>      </tr>

     <%else %>        <tr class="pictureclass"><td></td><td ></td></tr>        <tr class="pictureclass">        <td class="name"><%=t 'form.results.picture.'+c%></td>        <td><%= f.text_field c, :class=>"number"%></td>        </tr>

     <% end %>

  <% end %>        <tr class="pictureclass"><td></td><td><span class="right"><%= f.hidden_field :_destroy %><%= link_to_function t('form.results.picture.destroy'), "remove_fields(this, '.pictureclass')"%></span></td></tr>

When the html is inserted, there is a size="30" attribute for the text input field:

<input type="text" size="30" name="sample[treatments_attributes][0] [results_pictures_attributes][1273597816957][couchenum]" id="sample_treatments_attributes_0_results_pictures_attributes_1273597816957_couchenum" class="number">

But I have no idea how it got there. Any ideas?