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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:33:29+00:00 2026-06-18T09:33:29+00:00

I am kinda new to Jquery / JS and after a little help. I

  • 0

I am kinda new to Jquery / JS and after a little help. I realise there hopefully is a much better way to do this, and any help would be greatly appreciated.

I am building a form that can calculate a total. That is:

‘Cost’ x ‘(1 + percent(%))’ = ‘total cost’

I have it working nicely, though I want to make it so that if I change either the ‘percent‘ field, or the ‘cost‘ field then the total amount updates. At the moment only if you update the ‘cost‘ will the total update.

Hope that makes sense. Code is below.

$(document).ready(function(){

$("#cost").change(function() { 
var findprofit = parseFloat($("#cost").val());
var profit = (findprofit*.01)
var margin = parseFloat($("#percentage").val());
var total = profit*margin;
$(".profit_1_1").html(total);
var totalprofit = (total + findprofit);
$("#total").val(totalprofit);
});

<input type="text" name="cost" id="cost"  />
<input type="text" name="percentage" id="cost" percentage />
<input type="text" name="total" id="total" readonly />
  • 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-18T09:33:31+00:00Added an answer on June 18, 2026 at 9:33 am
    $("#cost, #percent").change(function() { 
        ...
    });
    

    Should do the trick.

    Edit: You’ll need to give your percent input an id of “percent”. Two elements may not have the same ID.

    <input type="text" name="cost" id="cost"  />
    <input type="text" name="percentage" id="percent" percentage />
    <input type="text" name="total" id="total" readonly />
    

    Also I’m not sure what that “percentage” is at the end of the input. Percentage isn’t a valid attribute.

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

Sidebar

Related Questions

I'm kinda new to jQuery, so this may be a silly question... My problem
This is probably jquery basics, but I can't find a solution after much googling.
I'm kinda new to jQuery and I did get the toggle function to work
I am kinda new to this Regex thing. When analyzing some code I frequently
I am very new to jQuery (I started this morning) and I am confused
I am kinda new in jquery and im facing a problem to drag an
Kinda New to Jquery and hit an issue regarding returned HTML. I am using
after using this excellent peace of software called FireWatir, I wonder if there is
I'm kind of new to jquery/ajax calls, I have this code below to pull
I'm kinda new in jquery & ajax. I have 2 problems. I have the

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.