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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:45:39+00:00 2026-06-17T21:45:39+00:00

I have 2 types of text inputs, positive and questionable. There are multiple sets

  • 0

I have 2 types of text inputs, positive and questionable. There are multiple sets of these inputs that I need to show the total after adding all the numbers entered into both types of inputs. eg: 2 positive + 2 questionable = Total: 4

Then, I need to find the percentage of positive vs questionable from that total.
eg: 50% positive and 50% questionable.

I want to add these totals and percentages up live as the user enters them.

So far I am not getting anywhere. Any ideas for the best way to do this? Should I use .blur or .each?

jsfiddle: http://jsfiddle.net/infatti/UjU4a/

Here is what I have so far but it is not working:

<label>How many positive?</label>
<input type="text" name="positive" class="observationPositive">
<br />

<label>How many questionable?</label>
<input type="text" name="questionable" class="observationQuestionable">
<br />

<hr />

<label>How many positive?</label>
<input type="text" name="positive" class="observationPositive">
<br />

<label>How many questionable?</label>
<input type="text" name="questionable" class="observationQuestionable">
<br />

<hr />

<h4><span  id="observationTotal"></span> Total</h4>
<h4><span  id="observationQuestionablePercentage"></span>% Questionable</h4>
<h4><span  id="observationPositivePercentage"></span>% Positive</h4>

$('.observationPositive').blur(function () {
    var sum = 0;
    $('.observationPositive').each(function() {
        sum += Number($(this).val());
    });
});​​​​​​​​​
$('#observationTotal').text(sum);
  • 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-17T21:45:40+00:00Added an answer on June 17, 2026 at 9:45 pm

    Assuming you mean “average of the values”. However, I could do with understanding more about what it is you are trying to achieve – you might want to pair up each positive input with a questionable input…

    $('.observationPositive, .observationQuestionable').on("change", function () {
        var sumP = 0,
            sumQ = 0,
            countP = 0,
            countQ = 0;
        $('.observationPositive').each(function(){
            countP++;
            sumP += Number($(this).val());
        });
        $('.observationQuestionable').each(function(){
            countQ++;
            sumQ += Number($(this).val());
        });
    
        var percentP = 100/(1 + (sumQ/sumP));
        var percentQ = 100 - percentP;
    
        $("#observationTotal").text(sumP + sumQ);
        $("#observationQuestionablePercentage").text(percentQ.toFixed(2));
        $("#observationPositivePercentage").text(percentP.toFixed(2));
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form in which there are both types of fieldsmeans inputs text
I have these text inputs in a table : <td><input type='text' name='arrondi_devis_ht' class='calcul_total' size='8'></td>
I have problem in adding autocomplete plugin to multiple text inputs in loop (no
I have several applications within my domain that accept similar inputs in text fields.
I have 2 inputs with the same id but different types: <input id='aid' type='text'
In PHP, does one have to sanitize these types of inputs: radio buttons, checkbox
I have a form in which there are both types of fields means inputs
I have a few simple html text inputs. I would like to check that
I have the following inputs: <input class=input-text type=text name=nombres id=nombres /> <input class=input-text type=text
I have generated inputs with price values. Example: <input type=text value=59,00/> Now I should

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.