The code is attached below and an attachment is included for data information.
I have attached a screen shot of data
Expand|Select|Wrap|Line Numbers
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Sample Tax Form</title>
- <style type="text/css">
- <!--
- body {
- font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
- font-size: 12px;
- font-style: normal;
- font-weight: normal;
- color: #000;
- background-color: #70B8B8;
- }
- .th {
- font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
- font-size: 14px;
- font-style: normal;
- font-weight: bold;
- color: #FFF;
- background-color: #066;
- border-top-style: none;
- border-right-style: none;
- border-bottom-style: solid;
- border-bottom-width: 1px;()
- border-left-style: none;
- }
- .fill {
- background-color: #C1E1E1;
- border-top-style: none;
- border-right-style: none;
- border-bottom-style: solid;
- border-left-style: none;
- border-bottom-color: #000;
- border-bottom-width: 1px;
- }
- .fill2 {
- background-color: #C1E1E1;
- border-top-style: none;
- border-right-style: none;
- border-bottom-style: none;
- border-left-style: none;
- border-bottom-color: #000;
- border-bottom-width: 1px;
- text-align: left;
- }
- table {
- margin-left: auto;
- margin-right: auto;
- border-bottom-color:#FFF;
- border-left-color:#FFF;
- border-right-color:#FFF;
- border-top-color:#FFF;
- }
- .line {
- background-color:#70B8B8;
- border-bottom: 0px solid #FFF;
- }
- -->
- </style>
- <script language="javascript">
- function currency(e)
- {
- var temp = parseFloat(e.value.replace(/,/g,""));
- if(isNaN(temp))
- temp = 0;
- //if(e.id == "taxable_income" || e.id == "subtotal")
- //temp = (temp > 0 ? -temp : temp);
- // e.style.color = "red";
- //e.style.color = "black";
- e.value = addcommas(temp.toFixed(2));
- }
- function addcommas(amount)
- {
- var delimiter = ","; // replace comma if desired
- var a = amount.split('.',2)
- var d = a[1];
- var i = parseInt(a[0]);
- if(isNaN(i)) { return ''; }
- var minus = '';
- if(i < 0) { minus = '-'; }
- i = Math.abs(i);
- var n = new String(i);
- var a = [];
- while(n.length > 3)
- {
- var nn = n.substr(n.length-3);
- a.unshift(nn);
- n = n.substr(0,n.length-3);
- }
- if(n.length > 0) { a.unshift(n); }
- n = a.join(delimiter);
- if(d.length < 1) { amount = n; }
- else { amount = n + '.' + d; }
- amount = minus + amount;
- return amount;
- }
- function calc3(){
- var c1 = parseFloat(document.getElementById("subtotal").value.replace(/,/g,""));
- var c2 = parseFloat(document.getElementById("fed_withhold").value.replace(/,/g,""));
- var c3 = parseFloat(document.getElementById("state_withhold").value.replace(/,/g,""));
- // Check for NaN's, and make sure debits are negative
- c1 = (isNaN(c1) ? 0 : c1);
- c2 = (isNaN(c2) ? 0 : (c2 > 0 ? -c2 : c2));
- c3 = (isNaN(c3) ? 0 : (c3 > 0 ? -c3 : c3));
- // Make sure we are dealing with values rounded to the nearest cent before calculating,
- c1 = parseFloat(c1.toFixed(2));
- c2 = parseFloat(c2.toFixed(2));
- c3 = parseFloat(c3.toFixed(2));
- var temp = c1 + c2 + c3;
- var cb = document.getElementById("total");
- cb.value = temp;
- currency(cb);
- }
- //---------------------------------------------------------------------------------------------------------------------------------------------------
- function calc4(){
- var d1 = parseFloat(document.getElementById("base_cash_value").value.replace(/,/g,""));
- var d2 = parseFloat(document.getElementById("cost_basis").value.replace(/,/g,""));
- // Check for NaN's, and make sure debits are negative
- d1 = (isNaN(d1) ? 0 : d1);
- d2 = (isNaN(d2) ? 0 : d2);
- // Make sure we are dealing with values rounded to the nearest cent before calculating,
- d1 = parseFloat(d1.toFixed(2));
- d2 = parseFloat(d2.toFixed(2));
- var temp = d1 - d2;
- var cb = document.getElementById("taxable_income");
- cb.value = temp;
- currency(cb);
- }
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- function calc5(){
- var c1 = parseFloat(document.getElementById("taxable_income").value.replace(/,/g,""));
- var c2 = parseFloat(document.getElementById("fed_withhold").value.replace(/,/g,""));
- var c3 = parseFloat(document.getElementById("state_withhold").value.replace(/,/g,""));
- // Check for NaN's, and make sure debits are negative
- c1 = (isNaN(c1) ? 0 : c1);
- c2 = (isNaN(c2) ? 0 : (c2 > 0 ? -c2 : c2));
- c3 = (isNaN(c3) ? 0 : (c3 > 0 ? -c3 : c3));
- // Make sure we are dealing with values rounded to the nearest cent before calculating,
- c1 = parseFloat(c1.toFixed(2));
- c2 = parseFloat(c2.toFixed(2));
- c3 = parseFloat(c3.toFixed(2));
- var temp = c1 + c2 + c3;
- var cb = document.getElementById("total");
- cb.value = temp;
- currency(cb);
- }
- //-------------------------------------------------------------------------------------------------------------------------------------------------
- function clearit()
- {
- var a = document.getElementById('subtotal').value;
- var b = document.getElementById('cost_basis');
- var c = document.getElementById('total');
- var d = document.getElementById('taxable_income');
- var e = document.getElementById('fed_withhold');
- var f = document.getElementById('state_withhold');
- b.value='';
- c.value='';
- d.value='';
- e.value='';
- f.value='';
- }
- //---------------------------------------------------------------------------------------------------------------------------------------------
- function fedWithhold(){
- var a = document.getElementById("tax_code")
- if(((a.value == "457 Pension") || (a.value == "HR-10")) || (a.value == "TSA") || (a.value == "Sepp IRA")){
- var c1 = parseFloat(document.getElementById("taxable_income").value.replace(/,/g,""));
- c1 = (isNaN(c1) ? 0 : c1);
- c1 = parseFloat(c1.toFixed(2));
- var v = 20;
- var p = 100;
- var temp = c1 / p;
- var temp2 = temp * v;
- var cb = document.getElementById('fed_withhold');
- cb.value = temp2;
- currency(cb);
- }
- var a = document.getElementById("tax_code")
- if((a.value == "IRA") || (a.value == "Non Qualified Annuity")|| (a.value == "Life/Disability")){
- var c1 = parseFloat(document.getElementById("taxable_income").value.replace(/,/g,""));
- c1 = (isNaN(c1) ? 0 : c1);
- c1 = parseFloat(c1.toFixed(2));
- var v = 10;
- var p = 100;
- var temp = c1 / p;
- var temp2 = temp * v;
- var cb = document.getElementById('fed_withhold');
- cb.value = temp2;
- currency(cb);
- }
- var a = document.getElementById("tax_code")
- if (a.value == "Roth IRA"){
- var c1 = parseFloat(document.getElementById("taxable_income").value.replace(/,/g,""));
- c1 = (isNaN(c1) ? 0 : c1);
- c1 = parseFloat(c1.toFixed(2));
- var v = 0;
- var p = 100;
- var temp = c1 / p;
- var temp2 = temp * v;
- var cb = document.getElementById('fed_withhold');
- cb.value = temp2;
- currency(cb);
- }
- }
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- function stateWithhold() {
- var a = document.getElementById('state').value
- b = document.getElementById('Yes')
- n = document.getElementById('No')
- c = parseFloat(document.getElementById("fed_withhold").value.replace(/,/g,""));
- t = parseFloat(document.getElementById("taxable_income").value.replace(/,/g,""));
- d = document.getElementById('tax_code')
- // State w/h %
- r = 5.3,
- q = 0,
- u = 25,
- v = 10,
- w = 4,
- x = 5,
- y = 21,
- z = 8,
- p = 100,
- tax = 0.00,
- c = (isNaN(c) ? 0 : c);
- c = c * 100; // Convert to integer for proper rounding
- t = (isNaN(t) ? 0 : t);
- t = t * 100; // Convert to integer for proper rounding
- var limit = 100000; // Alter this for proper rounding, too
- // California
- if (a === "CA" && b.checked && c >= limit) {
- tax = ((c * v) / 10000).toFixed(2); // w/h amount
- document.getElementById("state_withhold").value = tax;
- return false;
- calc5();
- }
- // Iowa
- if ((a === "IA") && (b.checked)){
- tax = ((t * x) / 10000).toFixed(2); // w/h amount
- }
- calc5();
- document.getElementById("state_withhold").value = tax;
- // Nebraska
- if (a === "NE" && b.checked){
- tax = ((c * y) / 10000).toFixed(2); // w/h amount
- }
- calc5();
- document.getElementById("state_withhold").value = tax;
- // Oregon
- if (a === "OR" && b.checked){
- tax = ((t * z) / 10000).toFixed(2); // w/h amount
- }
- calc5();
- document.getElementById("state_withhold").value = tax;
- // Maine
- if (a === "ME" && b.checked){
- tax = ((t * x) / 10000).toFixed(2); // w/h amount
- }
- calc5();
- document.getElementById("state_withhold").value = tax;
- // Vermont
- if (a === "VT" && b.checked){
- tax = ((c * u) / 10000).toFixed(2); // w/h amount
- }
- calc5();
- document.getElementById("state_withhold").value = tax;
- // Virginia
- if (a === "VA" && b.checked){
- tax = ((t * w) / 10000).toFixed(2); // w/h amount
- }
- calc5();
- document.getElementById("state_withhold").value = tax;
- // Other States
- if ( n.checked){
- tax = ((t * q) / 10000).toFixed(2); // w/h amount
- }
- calc5();
- document.getElementById("state_withhold").value = tax;
- }
- //------------------------------------------------------------------------------------------------------------------------------------------------
- function annunity(){
- var x = document.getElementById('state').value
- b = document.getElementById('Yes')
- t = parseFloat(document.getElementById('taxable_income').value.replace(/,/g,""));
- s = document.getElementById('tax_code')
- r = 5.3,
- v = 10,
- tax = 0.00,
- t = (isNaN(t) ? 0 : t);
- t = t * 100; // Convert to integer for proper rounding
- // Massachusetts
- if ((x === "MA") && (b.checked) && (s.value === "IRA" || "HR-10" || "TSA" || "Sepp IRA" || "457 Pension" || "Roth IRA"))
- {
- tax = ((t * r) / 10000).toFixed(2); // w/h amount
- }
- calc5();
- document.getElementById("state_withhold").value = tax;
- if (x === "MA" && b.checked && s.value === "Life/Disability")
- {
- tax = ((t * v) / 10000).toFixed(2); // w/h amount
- }
- calc5();
- document.getElementById("state_withhold").value = tax;
- }
- </script>
- </head>
- <body>
- <form name="theform" method="post" action="" >
- <table width="652" border="0" cellspacing="1" cellpadding="1" bgcolor="#C1E1E1" >
- <tr>
- <th class="th" colspan="3">Check Request Worksheet</th>
- </tr>
- <tr>
- <td align="right" ></td>
- <td></td>
- </tr>
- </table>
- <table width="652" border="0" cellspacing="1" cellpadding="1" bgcolor="#C1E1E1" >
- <tr >
- <td colspan="3"class="line"> </td>
- </tr>
- </table>
- <table width="655" border="0" cellspacing="0" cellpadding="0" bgcolor="#C1E1E1" id="A" style="display:block">
- <tr >
- <td colspan="4"><table width="655" border="0" cellspacing="1" cellpadding="1" bgcolor="#C1E1E1" >
- <tr >
- <td width="190" align="right">Base Cash Value:</td>
- <td width="459"><input type="text" class="fill" name="" id="base_cash_value"style="text-align:right" onblur="currency(this)"/></td>
- </tr>
- <tr>
- <td align="right"> - Cost Basis:</td>
- <td width="459"><input type="text" class="fill" name="cost_basis" id="cost_basis" onkeyup="calc4(); "style="text-align:right" onblur="currency(this)"/></td>
- </tr>
- <tr>
- <td width="186" align="right"><b>Taxable Income:</b></td>
- <td width="459"><input type="text" class="fill" name="taxable_income" id="taxable_income" style="text-align:right"/></td>
- </tr>
- </table></td>
- </tr>
- </table>
- </tr>
- </tr>
- <table width="655" border="0" cellspacing="0" cellpadding="0" bgcolor="#C1E1E1" id="C" style="display:block">
- <tr >
- <td colspan="4"></td>
- </tr>
- </table>
- </tr>
- <table width="655" border="0" cellspacing="1" cellpadding="1" bgcolor="#C1E1E1" id="D">
- <tr>
- <td align="right">Taxation: </td>
- <td><select name="tax code" id="tax_code" onchange="document.theform.showValueA.value=this.value;fedWithhold();calc5();">
- <option value=""></option>
- <option value="IRA">I</option>
- <option value="HR-10">H</option>
- <option value="Non Qualified Annuity">N</option>
- <option value="TSA">O</option>
- <option value="Sepp IRA">S</option>
- <option value="457 Pension">P</option>
- <option value="Roth IRA">Q</option>
- <option value="Life/Disability">X</option>
- </select>
-
- <input type="text" class="fill2" name="showValueA" size="30"/></td>
- </tr>
- <tr>
- <td align="right">Federal Withholding:</td>
- <td width="458"><input type="text" class="fill" name="" id="fed_withhold" style="text-align:right" onkeyup="calc3();"onblur="currency(this)" />
- (Account 271700700)</td>
- </tr>
- <tr>
- <td align="right">Withhold:</td>
- <td>
- <input type="checkbox" id="Yes" onclick="stateWithhold();annunity();"/>
- Yes
- <input type="checkbox" id="No" />
- No
- State:
- <select name="OBKey__181_1" id="state" tabindex="30" onchange="stateWithhold();annunity();">
- <option value=""> </option>
- <option value="CA">CA </option>
- <option value="IA">IA </option>
- <option value="KS">KS </option>
- <option value="MA">MA </option>
- <option value="NE">NE </option>
- <option value="OR">OR </option>
- <option value="VT">VT </option>
- <option value="VA">VA </option>
- </select></td>
- </td>
- </tr>
- <tr>
- <td align="right">State Withholding:</td>
- <td width="458"><input type="text" class="fill" name="" id="state_withhold"style="text-align:right" onkeyup="calc3();" onblur="currency(this)" />
- (Account 271701100)</td>
- </tr>
- <tr>
- <td align="right"><b>Check Total:</b></td>
- <td width="458"><input type="text" class="fill" name=""id="total" style="text-align:right" onblur"currency(this)"/>
- </tr>
- <tr>
- <td colspan="3"align="center"><input type="submit" value="Submit" name="OBBtn_Yes">
- </tr>
- </table>
- </form>
- </body>
- </html>