title: javascript add variable to input field rails
body: <p>I have a Javascript variable which gets the value of the select box. I would like to append input field with value = the value of select box. However, could not get this to work.</p>
  
  <pre><code>$(function () {
      $(document).on("change", "#extra_crew", function (e) {
          var extra_crew = $('#extra_crew').val();
          $('#extra_crew_area').append(
                  ' &lt;div class="col-sm-12 m-t-10 m-b-10 no-padding"&gt;'
                  + '&lt;%= text_field_tag :reservation_type, "", class: "form-control m-b-10", :value =&gt; "' 
                  + extra_crew 
                  + '" %&gt;'
                  + '&lt;/div&gt;');
          console.log(extra_crew);
      });
  });
  </code></pre>
  
  <p>It works just fine but extra_crew seems a string in the input field could not concatenate. </p>
  
  <p>Then it shows like this.</p>
  
  <p><a href="https://i.stack.imgur.com/Y3zSO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y3zSO.png" alt="enter image description here"></a></p>