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 8479841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:08:42+00:00 2026-06-10T19:08:42+00:00

i am trying to get amount of a bill through getJSON method. Though i

  • 0

i am trying to get amount of a bill through getJSON method. Though i am getting the amount, i am not able to post it. The code is as follows.

in the form

<div class="bill">
<%= f.collection_select :customer_bill_id, CustomerBill.all,:id,:id, {:prompt => "Select Customer bill"} %></div><br />

<div class= "due"><%= f.input :bill_due_amount, :label => "Bill Due Amt.", :input_html => { :size => 20} %> </div><br />

the js

jQuery(".bill select").bind("change", function() {
        var data = {
        customer_bill_id: jQuery(this).val()  
      }
      jQuery.getJSON(
         "/money_receipts/get_due_amount",
        data,
        function(data){
          var res = "";
      res =  parseFloat(data[0]);
      getAmount = jQuery('.due').val(res);
        });      
    });

and in the controller i have

def get_due_amount
    @due_amount = CustomerBill.find_all_by_id(params[:customer_bill_id]).map{|bill| [bill.bill_due_amount]}if params[:customer_bill_id]
    respond_to do |format|
      format.json { render json: @due_amount }
    end
  end

if i do alert(res); i do get the amount value but when i do

getAmount = jQuery('.due').val(res);
        alert(getAmount);

i get [object Object]

what seems to be the problem? why is the value not appearing in the form? seeking guidance. Thanks 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-10T19:08:44+00:00Added an answer on June 10, 2026 at 7:08 pm

    You used jQuery(‘.due’), but this is a div element. Fou need to do the following way to set form input value,

    jQuery('.due input').val(res); 
    

    It will set the amout to textbox value.

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

Sidebar

Related Questions

I'm trying to get the total amount of Milliseconds ( not the millis field)
I'm trying to get the amount of images which are stored in the post-content
I am trying to get HTML code from a webpage that is not in
i'm trying to get this program to break down a user defined amount of
Im trying to get the amount of elements in an array using the count()
I am trying to get the different amount of colors inside an image in
Anyone can help me with this statement? I'm trying to get amount of beads
I'm currently trying to get the amount of appearences of each word in a
I'm trying to get it so, every time someone donates a set amount on
I'm trying to get the maximum amount a scrollviewer can scroll in the vertical

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.