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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:23:29+00:00 2026-05-26T05:23:29+00:00

I have a textfield and I need to add their values. The problem is

  • 0

I have a textfield and I need to add their values. The problem is that the values in these textfields are not typed in but got from another source. These text fields also happen to be read only.
What I need is the appropriate event to fire when the values of these textfields change. Here is what i am currently using but its not good enough since I have to click and lose focus so that the textfields calculate. FYI .change and .click events don’t work well either. I need the values summed up immediately they change dynamically. #grandmealstotal is one of the textfields that needs to be added, #usdgrandaccomtotal is the other textfield that needs to be added. results are alerted out and displayed in a textfield with id #gross_tripexpense. Below is what I’m using

$("#grandmealstotal").live('blur',function(){
var mealtotal=parseFloat($("#grandmealstotal").val());
var accomtotal=parseFloat($("#usdgrandaccomtotal").val());
var grosstotals=parseFloat(accomtotal+mealtotal);
alert(grosstotals)
$("#gross_tripexpense").val((grosstotals).toFixed(2));
})

Any help appreciated.

  • 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-05-26T05:23:30+00:00Added an answer on May 26, 2026 at 5:23 am

    You could use the .keydown() or .keyup() event in this case:

    $('#grandmealstotal').keyup(function() {
        var mealtotal = parseFloat($('#grandmealstotal').val());
        var accomtotal = parseFloat($('#usdgrandaccomtotal').val());
        var grosstotals = parseFloat(accomtotal + mealtotal);
        alert(grosstotals);
        $('#gross_tripexpense').val((grosstotals).toFixed(2));
    });
    

    Also make sure that you perform error handling as those parseFloat methods could fail if the user enters invalid numbers. You could use the isNaN function for this:

    var mealtotal = parseFloat($('#grandmealstotal').val());
    if (!isNaN(mealtotal)) {
        // use the mealtotal variable here
    } else {
        alert('please enter a valid number for total meals');
    }
    

    UPDATE:

    If the values are readonly and cannot change you could perform the calculation once the DOM is ready:

    $(function() {
        ... do the calculation here
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text field (flash.display.textField) for editing, but the default font does not
I have a simple jasper report that does not need a datasource so I
In my view i have Textfield.If i move that TextField it should open iphone
I have a textfield which displays a result but I don't want it to
I have an odd issue while using FlashCS4. I have a textfield that, when
for example, I have a textfield, that records the user name, after I click
I have a UITable View with a textfield that is editable right on the
I am tying to add the values from an array to a number of
I have the following table structure: EVENT_ID(INT) EVENT_NAME(VARCHAR) EVENT_DATE(DATETIME) EVENT_OWNER(INT) I need to add
I need to return som values I have selected in a jQuery UI Dialog

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.