Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:09:16+00:00 2026-06-11T08:09:16+00:00

Hello guys i am trying attempt a dynamic select here. as soon as i

  • 0

Hello guys i am trying attempt a dynamic select here. as soon as i select the customer his total value in the bill should come and get displayed in the text field tag.

the view

  jQuery(document).ready(function(){
   jQuery(".customerid").bind("change", function() { 

      var data = {
        customer_id: jQuery(".customerid :selected").val()  
      }
      jQuery.ajax({
        url: "get_cust_bill",
        type: 'GET',
        dataType: 'script',
        data: data
      });
    });
  });
</script>


 <div class ="customerid"><%= f.label :customer_id %>
    <%= f.collection_select :customer_id, Customer.all, :id, :name, options ={:prompt => "-Select a Customer"}, :class => "state", :style=>'width:210px;'%></div><br />

     <div class ="customerbill">
      <%= f.label :total_value, "Total Value" %>
  <%= render :partial => "customerbill" %>

js.erb file

jQuery('.customerbill').html("<%= escape_javascript(render :partial => 'customerbill') %>");

the customerbill partial

<% options = []
  options = @cust_bill.total_value if @cust_bill.present? %>
<%= text_field_tag "total_value", options %>

in contoller

def get_cust_bill
    @cust_bill = CustomerBill.find_all_by_customer_id(params[:customer_id]) if params[:customer_id]
  end

I feel the problem lies in the partial, the way i am calling the options so can anyone guide me how to get the value in text field??? thank in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:09:18+00:00Added an answer on June 11, 2026 at 8:09 am

    i was using getJSON method….and i feel that can be used here. hope the followng works.

    jQuery(document).ready(function()
        {
        jQuery(".customerid select").bind("change", function() {
              var data = {
                product_id: jQuery(this).val()  
              }
              jQuery.getJSON(
                 "/controller_name/get_cust_bill",
                data,
                function(data){
              var result = "";
              res = parseFloat(a[1]);
               jQuery('.price input').val(res);
              });            
                });
            });
    

    controller

    def get_cust_bill
        @cust_bill = CustomerBill.find_all_by_customer_id(params[:customer_id]).map{|p| [p.price]} if params[:customer_id]
    respond_to do |format|
          format.json { render json: @cust_bill }
        end
      end
    

    so no need of calling js. erb partial you can simply have

    <div class = "price"><%= f.input :price, :label => 'Price', :input_html => { :size => 20} %></div><br/>
    

    all the best 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys I'm trying to send a cookie with http post in android here's
hello guys I am trying to extract all the anchor links from aol but
hello guys i am trying to print title from a set of urls in
Hello guys i'm facing a isolated exception when trying to edit my UI it
Hello guys look to my code I'm trying to make a program which asks
Hello guys, I have been trying to implement the DSUM function but failed to
Hello Guys I am trying to figure out why i am gettings this error
Hello guys. I trying set EditText to input only numbers and point ( .
Hello guys Im trying to set a max width and height so that when
Hello guys i'm having one hell of a time trying to parse an xml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.