title: How to pass html values in Ruby within a Javascript function
body: <p>I have  a view page, where the user inputs a number and clicks on generate to get a form  in the same page based on this input. So I'm using javascript in my main view:</p>
  
  <pre><code> &lt;div class="label-field-pair"&gt;&lt;%= "#{t('total')} #{t('amount')}" %&gt;:
      &lt;%= form.text_field :total, :value =&gt;precision_label(@total_pay.to_f)  , :disabled=&gt; true , :id=&gt;'total' %&gt;&lt;/div&gt;
  
  
        &lt;div class="label-field-pair"&gt;
          &lt;label for="student_grade"&gt;&lt;%= t('no_payments') %&gt;&lt;span class="necessary-field"&gt;*&lt;/span&gt; &lt;/label&gt;
          &lt;input type="number" min="1" max="12" step="1" value="1" name="no_payments" id="no_payments"&gt;      &lt;/div&gt;
         &lt;%= form.hidden_field :no_payments, :id=&gt;'payments' %&gt;
         &lt;%= form.hidden_field :total_pay, :id=&gt;'total_pay' %&gt;
  
      &lt;%#= submit_tag "", :value =&gt; "► #{t('generate')}", :class =&gt; "submit_button", :disable_with =&gt; "► #{t('please_wait')}" %&gt;
      &lt;%#= render :partial =&gt; 'distribute_payments', :locals =&gt; {:no_payments=&gt;2, :total =&gt; 30000 , :guardian=&gt;@guardian.id} %&gt;
      &lt;button type="button" id="gen" onClick="generate()" style="display: block"&gt;Generate&lt;/button&gt;
      &lt;div id="payments_distribute"&gt;&lt;/div&gt;
     &lt;%end%&gt;
  
  
  
    &lt;script type="text/javascript"&gt;
  
         function generate() {
  
  
            var t = document.getElementById("total").value;
            var n = document.getElementById("no_payments").value;
            j('#total_pay').val("&lt;%= @total_pay %&gt;");
           document.getElementById("gen").style.display = "none";
  
            &lt;%="#{remote_function(:url =&gt; {:action =&gt; "distribute_payments", :id=&gt;@guardian.id,:total_pay=&gt;@total_pay}
  
            )}"%&gt;
        }
  
  
  
    &lt;/script&gt;
  </code></pre>
  
  <p>And this is the action for my partial view:</p>
  
  <pre><code>  def distribute_payments
      @total_amount=params[:total]
        @no_payments=params[:no_payments]
        @total_payment=params[:total_pay]
       @guardian = Guardian.find(params[:id])
      @students=Student.find_all_by_sibling_id(@guardian.ward_id)
  
        render(:update) do |page|
              page.replace_html 'payments_distribute', :partial=&gt;'distribute_payments', :total_pay=&gt;@total_payment, :no_payments=&gt;@no_payments
           end
    end
  </code></pre>
  
  <p>The problem here is that I need to pass the value of "no_payments" with the parameters to my partial view, and I don't know how to do this from my Javascript function (remote_function). I was trying to use render_partial with a submit button, but I wasn't able to open the partial view in the same page. You can check my question here: <a href="https://stackoverflow.com/questions/32991382/rails-render-partial-from-controller">Rails: Render Partial from controller</a></p>