Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. change in cell content of salary or bonus or deduction in table cells automatically affect in total

change in cell content of salary or bonus or deduction in table cells automatically affect in total

Scheduled Pinned Locked Moved JavaScript
javascripthtmlcssdatabasetools
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ahmed_sa
    wrote on last edited by
    #1

    Hi i have table have 5 comnun Name Salary Bonus Deduction Total Ahmed 500 500 100 900 calculation of total is Total=Salary+Bonus-Deduction and total in red color according to my code what i need actually if i changed in Salary cell or Bonus cell or Deduction cell affect in total cell suppose i added row above then edit salary from 500 to 2000 meaning in this time row will be as bellow Ahmed 2000 500 100 2400 total will be 2400 with green color i can do by button but how to do by changing cell in table affect in total @{ Layout = null; } <html> <head> <meta name="viewport" content="width=device-width" /> <title>Index</title> <script src="~/Scripts/jquery-1.10.2.js"></script> <script> $(function () { $("#btn").click(function () { var x = $("#txt1").val(); var y = $("#txt2").val(); var z = $("#txt3").val(); var M = $("#txt4").val(); var L = parseInt(y) + parseInt(z) - parseInt(M); $("#tb").append(" " + x + " " + y + " " + z + "" + M + "" + L + ""); $("#tb tr").each(function () { var total = $(this).find("td:nth-child(5)").html(); if(parseInt(total)>1000) { $(this).find("td:nth-child(5)").css("background-color", "green"); } if (parseInt(total) < 1000) { $(this).find("td:nth-child(5)").css("background-color", "red"); } if (parseInt(total) == 1000) { $(this).find("td:nth-child(5)").css("background-color", "yellow"); } }); }); $("#tb").on("click", "tr", function () { $(this).find("td").slice(0, 4).prop("contenteditable", true); }); }); </script> .red{ color:#ff0000; font-weight:bold; } </head> <body>

    Name<input type="text" id="txt1" />
    Salary<input type="text" id="txt2" />
    Bonus<input type="text" id="txt3" />
    Deduction<input t

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups