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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:46:46+00:00 2026-05-27T20:46:46+00:00

Here’s the latest JSFiddle . HTML: <table id=math-table> <tr> <td><input type=text id=A1 name=A value=></td>

  • 0

Here’s the latest JSFiddle.

HTML:

<table id="math-table">
    <tr>
           <td><input type="text" id="A1" name="A" value=""></td>
           <td><input type="text" id="B1" name="B" value=""></td>
           <td><input type="text" id="C1" name="C" readonly="readonly" tabIndex="-1" value=""></td>
      </tr>
</table> 

JS:

$("#math-table input").live("keyup", function(){
var id = this.id.match(/\d+/);
$("#C"+id).val( Math.round (($("#A"+id).val() / $("#B"+id).val()) * 100) + "%"  );

$('#A'+id).attr('value', $('#A'+id).val());  
$('#B'+id).attr('value', $('#B'+id).val());  
$('#C'+id).attr('value', $('#C'+id).val());  
});

var uniqueIds = $("#math-table tr").length;
$("#math-table input[id^='B']").live("change", function(){
var $thisRow = $(this).closest("tr"),
$clone = $thisRow.clone(),             // Clone row
$inputs = $clone.find("input").val("");// Reset values, return all inputs
uniqueIds++; //Increment ID
$inputs[0].id = "A" + uniqueIds;
$inputs[1].id = "B" + uniqueIds;
$inputs[2].id = "C" + uniqueIds;
$thisRow.after($clone);                    
});

You can see that A/B = C% Pretty simple. How would I add a different CSS class to only C based on a certain %?

Red 1-33%

Green 34-66%

Blue 67-100%

  • 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-27T20:46:47+00:00Added an answer on May 27, 2026 at 8:46 pm

    I updated your jsFiddle:

    http://jsfiddle.net/CzZxf/13/

    I added a variable percent and set the background color based on that like this:

      if(percent>0 && percent<34)
        $('#C'+id).addClass("red");
    if(percent>33 && percent<67)
        $('#C'+id).addClass("green");
    if(percent>67)
        $('#C'+id).addClass("blue");
    

    EDIT: I updated the script to remove the class from the clone. Add this

    $inputs = $clone.find("input").val("").removeClass();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here is what I want to do. Use this HTML line and have the
Here an example of my checkbox list http://jsfiddle.net/YnM2f/ Let's say I check on G
Here is a snippet of my xaml: <ComboBox x:Name=cbo1 Width=100 SelectedValue=200> <ComboBoxItem Name=n1>100</ComboBoxItem> <ComboBoxItem
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Here my code: $(document).ready(function() { $('#mid_select').live('click', function(e){ $('#middle').load( $(this).attr('href') + ' #middle'); var page
here is the scenario 1: user starts to type some word, autocomplete engine shows
Here is an example: I write html code inside of textarea, then I swap
here is my configuration: http://domain.com (obviously fictitious name...) hosted on a server running Apache
Here's an example query: DECLARE @table table (loc varchar(10)) INSERT INTO @table VALUES ('134a'),

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.