I need advice on calculating some totals in jquery -


i'm new programming please excuse if it's not best question!

i'm trying create calculator using jquery.calculation.js plugin. have far lets enter basic salary of person 1, , basic salary of person 2, displays both basic salaries. lets enter quarterly bonus of each person, , displays determines 'actual quarterly' bonus (which user has entered x 0.6)

what i'm confused need sum person 1's actual quarterly , basic income, , same person 2, , output these values grand_total1 , grandtotal2 rows in table, whatever cannot make work. here have far. ideas?

thanks.

<script type="text/javascript" src="jquery.field.min.js"></script> <script type="text/javascript" src="jquery.calculation.js"></script>  <script type="text/javascript"> var bisfirebugready = (!!window.console && !!window.console.log);  $(document).ready(     function (){         // update plug-in version         $("#idpluginversion").text($.calculation.version);  /*                   $.calculation.setdefaults({             onparseerror: function(){                 this.css("backgroundcolor", "#cc0000")             }             , onparseclear: function (){                 this.css("backgroundcolor", "");             }         }); */          // bind recalc function  fields         $("input[name^=quarterly_bonus_]").bind("keyup", recalc);             $("input[name^=basic_salary_]").bind("keyup", recalc);         // run calculation function         recalc();        } );  function recalc(){           $("[id^=actual_quarterly_]").calc(         // equation use calculation         "statedquarterly * factor",                     {             statedquarterly: $("input[name^=quarterly_bonus_]"),             factor: 0.6         },                     function (s){             // return number dollar amount             return "£" + s.tofixed(2);         },                     function ($this){             // sum total of $("[id^=total_item]") selector             var sum1 = $this.sum();             $("#grandtotal").text(                 // round results 2 digits                 "£" + sum1.tofixed(2)             );          }     );      $("[id^=actual_basic_]").calc(         // equation use calculation         "qty",                     {             qty: $("input[name^=basic_salary_]")          },                     function (s){             // return number dollar amount             return "£" + s.tofixed(2);         },                     function ($this){             // sum total of $("[id^=total_item]") selector             var sum = $this.sum();              $("#grandtotal2").text(                 // round results 2 digits                 "£" + sum.tofixed(2)             );         }     );   }   </script>    <table width=1000" style="font-size:1em;">            <col style="width: 150px;" />            <col style="width: 150px;" />             <col style="width: 150px;" />                     <col style="width: 150px;" />             <col style="width: 150px;" />                 <col style="width: 150px;" />             <tr>                      <th style="font-size:0.9em;"                  </th>                  <th style="font-size:0.9em;">                     insert figures column                 </th>                       <th style="font-size:0.9em;">                     applicant 1                 </th>               <th style="font-size:0.9em;">                     insert figures column                 </th>                   <th style="font-size:0.9em;">                     applicant 2                 </th>             </tr>              <tr>                 <td>basic salary (annual value)</td>                 <td align="center"> <input type="text" name="basic_salary_1" id="basic_salary_1" value="0" size="5" />                 </td>                  <td align="center" id="actual_basic_1">                     --                 </td>                  <td align="center"> <input type="text" name="basic_salary_2" id="basic_salary_2" value="0" size="5" />                 </td>                  <td align="center" id="actual_basic_2">                     --                 </td>             </tr>              <tr>                 <td>quarterly bonus (annual value)</td>     <td align="center">   <input type="text" name="quarterly_bonus_1" id="quartlery_bonus_1"  value="0" size="5" />                 </td>                  <td align="center" id="actual_quarterly_1">                     --                 </td>                  <td align="center">         <input type="text"         name="quarterly_bonus_2" id="quarterly_bonus_2"   value="0" size="5" />                 </td>                  <td align="center" id="actual_quarterly_2">                     --                 </td>             </tr>                  <tr>                 <td colspan="2" align="right">                     <strong>grand total 1:</strong>                 </td>                  <td align="center" id="grandtotal1">                 </td>                     <td colspan="1" align="right">                     <strong>grand total 2:</strong>                 </td>                  <td align="center" id="grandtotal2">                 </td>             </tr>            </table> 


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -