计算html / Javascript表单

时间:2013-01-30 02:38:18

标签: javascript html forms

我正在尝试使用数量和添加来计算此表单,某些字段具有所需的金额,其他字段是输入的数量和金额。我想把所有这些加在一起并申请税。任何帮助将非常感激。以下是我正在使用的Excel电子表格的链接:Estimator Form

以下是我目前的代码:

function bizAmt(amount) {
  string = "" + amount;
  dec = string.length - string.indexOf('.');
  if (string.indexOf('.') == -1)
    return string + '.00';
  if (dec == 1)
    return string + '00';
  if (dec == 2)
    return string + '0';
  if (dec > 3)
    return string.substring(0, string.length - dec + 3);
  return string;
}

function calculate() {
  QtyA = 0;
  QtyB = 0;
  QtyC = 0;
  TotA = 0;
  TotB = 0;
  TotC = 0;

  PrcA = 65;
  PrcB = 88;
  PrcC = 132;

  if (document.getElementById("qtyA").value > "") {
    QtyA = document.getElementById("qtyA").value
  };
  document.getElementById("qtyA").value = eval(QtyA);

  if (document.getElementById("qtyB").value > "") {
    QtyB = document.getElementById("qtyB").value
  };
  document.getElementById("qtyB").value = eval(QtyB);

  if (document.getElementById("qtyC").value > "") {
    QtyC = document.getElementById("qtyC").value
  };
  document.getElementById("qtyC").value = eval(QtyC);


  TotA = QtyA * PrcA;
  document.getElementById("totalA").value = bizAmt(eval(TotA));

  TotB = QtyB * PrcB;
  document.getElementById("totalB").value = bizAmt(eval(TotB));

  TotC = QtyC * PrcC;
  document.getElementById("totalC").value = bizAmt(eval(TotC));


  Totamt =
    eval(TotA) +
    eval(TotB) +
    eval(TotC);

  document.getElementById("GrandTotal").value = bizAmt(eval(Totamt));
}

function validNum(theForm) {
  var checkOK = "0123456789.,";
  var checkStr = theForm.qtyA.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    if (ch == ".") {
      allNum += ".";
      decPoints++;
    } else if (ch == "," && decPoints != 0) {
      validGroups = false;
      break;
    } else if (ch != ",")
      allNum += ch;
  }
  if (!allValid) {
    alert("Please enter only digit characters in the \"Truck Fuel Charge quantity\" field.");
    theForm.qtyA.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups) {
    alert("Please enter a valid number in the \"Truck Fuel Charge quantity\" field.");
    theForm.qtyA.focus();
    return (false);
  }

  var checkOK = "0123456789.,";
  var checkStr = theForm.qtyB.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";

  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    if (ch == ".") {
      allNum += ".";
      decPoints++;
    } else if (ch == "," && decPoints != 0) {
      validGroups = false;
      break;
    } else if (ch != ",")
      allNum += ch;
  }
  if (!allValid) {
    alert("Please enter only digit characters in the \"contract Labor quantity\" field.");
    theForm.qtyB.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups) {
    alert("Please enter a valid number in the \"contract Labor quantity\" field.");
    theForm.qtyA.focus();
    return (false);
  }

  var checkOK = "0123456789.,";
  var checkStr = theForm.qtyC.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";

  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
    if (ch == ".") {
      allNum += ".";
      decPoints++;
    } else if (ch == "," && decPoints != 0) {
      validGroups = false;
      break;
    } else if (ch != ",")
      allNum += ch;
  }

  if (!allValid) {
    alert("Please enter only digit characters in the \"contract Labor OT quantity\" field.");
    theForm.qtyC.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups) {
    alert("Please enter a valid number in the \"contract Labor OT quantity\" field.");
    theForm.qtyC.focus();
    return (false);
  }

  calculate();
  return (true);
}
body {
  background: #FFFFFF;
}
<h2>Estimator</h2>
<br />
<table border="0" cellpadding="0" width="550" id="table2">
  <tr>
    <td width="250" height="31"><b>Item Description</b>
    </td>
    <td align="center" width="100" height="31"><b>Quantity</b>
    </td>
    <td align="right" height="31" width="60"><b></b>
    </td>
    <td align="right" height="31" width="140"><b>Total</b>
    </td>
  </tr>
  <tr>
    <td width="250">Truck & Fuel Surcharge</td>
    <td align="center" width="100">
      <input type="text" value="" name="qtyA" id="qtyA" size="5" tabindex="5">
    </td>
    <td align="right" type="hidden" width="60">$65</td>
    <td align="right" width="140">
      <input readonly style="border:0px;" tabindex="99" name="totalA" id="totalA" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td width="250">Contract Labor</td>
    <td align="center" width="100">
      <input type="text" name="qtyB" id="qtyB" size="5" tabindex="5">
    </td>
    <td align="right" type="hidden" width="60">$88</td>
    <td align="right" width="140">
      <input type="hidden" name="totalB" id="totalB" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td width="250">Contract Labor OT</td>
    <td align="center" width="100">
      <input type="text" name="qtyC" id="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" type="hidden" width="60">$132</td>
    <td align="right" width="140">
      <input type="hidden" name="totalC" id="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td width="250">Non Contract Labor</td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" type="hidden" width="60">$98</td>
    <td align="right" width="140">
      <input type="hidden" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td width="250">Non Contract Labor OT</td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" type="hidden" width="60">$147</td>
    <td align="right" width="140">
      <input type="hidden" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td width="250"><b>Parts Description</b>
    </td>
    <td align="center" width="100">
      <td align="right" width="140">
      </td>
  </tr>
  <tr>
    <td width="250">Compressor</td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td width="250">Contactors</td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td width="250">Oil Pressure Switch</td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td width="250">Core Driers</td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td>
      <input type="text" name="input1" size="25">
    </td>
    </td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td>
      <input type="text" name="input1" size="25">
    </td>
    </td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td>
      <input type="text" name="input1" size="25">
    </td>
    </td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td>
      <input type="text" name="input1" size="25">
    </td>
    </td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td>
      <input type="text" name="input1" size="25">
    </td>
    </td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td>
      <input type="text" name="input1" size="25">
    </td>
    </td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td>
      <input type="text" name="input1" size="25">
    </td>
    </td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td>
      <input type="text" name="input1" size="25">
    </td>
    </td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td>
      <input type="text" name="input1" size="25">
    </td>
    </td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">$
      <input type="text" name="totalC" size="12" tabindex="99">
    </td>
  </tr>

  <tr>
    <td width="250">Leak Check</td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">
      <input type="hidden" name="totalC" size="12" tabindex="99">
    </td>
  </tr>
  <tr>
    <td width="250">Recovery #</td>
    <td align="center" width="100">
      <input type="text" name="qtyC" size="5" tabindex="5">
    </td>
    <td align="right" width="60"></td>
    <td align="right" width="140">&nbsp;</td>
  </tr>
  <tr>
    <td width="250">&nbsp;</td>
    <td align="center" width="100">&nbsp;</td>
    <td align="right" width="60">&nbsp;</td>
    <td align="right" width="140">&nbsp;</td>
  </tr>
  <tr>
    <td align="center" width="40">&nbsp;</td>
    <td align="right" width="60">&nbsp;</td>
    <td width="250">
      <p align="right"><b>Tax:</b>
    </td>
    <td align="right" width="250">$
      <input name="Tax" id="Tax" size="15" readonly style="border:0px;" tabindex="99">
    </td>
  </tr>
  <tr>
    <td align="center" width="40">&nbsp;</td>
    <td align="right" width="60">&nbsp;</td>
    <td width="250">
      <p align="right"><b>GRAND TOTAL:</b>
    </td>
    <td align="right" width="250">$
      <input name="GrandTotal" id="GrandTotal" size="15" readonly style="border:0px;" tabindex="99">
    </td>
  </tr>
  <tr>
    <td align="center" width="40">&nbsp;</td>
    <td align="right" width="60">&nbsp;</td>
    <td width="250">
      <p align="right"><b>COMMISSION:</b>
    </td>
    <td align="right" width="250">$
      <input type="text" name="Commission" id="Commission" size="15" tabindex="99" readonly style="border:0px;" tabindex="99">
    </td>
  </tr>
  <tr>
    <td width="250">&nbsp;</td>
    <td align="center" width="100">&nbsp;</td>
    <td align="right" width="60">&nbsp;</td>
    <td align="right" width="140">&nbsp;</td>
  </tr>
</table>

我使用form标签有工作代码,但我无法弄清楚如何使用getElementId。

见下文:

<html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>HVAC Estimator</title>
    <style type="text/css">
    .totals
            {
                font-size: .9em;

            }
    </style>

    <script language=javascript>
    <!--//

    function leeAmt(amount) 
    {
      string = "" + amount;
      dec = string.length - string.indexOf('.');
      if (string.indexOf('.') == -1)
      return string + '.00';
      if (dec == 1)
      return string + '00';
      if (dec == 2)
      return string + '0';
      if (dec > 3)
      return string.substring(0,string.length-dec+3);
      return string;
    }



    function calculate()
    {

      QtyA = 0;  QtyB = 0;  QtyC = 0; 
      TotA = 0;  TotB = 0;  TotC = 0;

      PrcA = 65; PrcB = 88; PrcC = 132;



      if (document.ofrm.qtyA.value > "")
         { QtyA = document.ofrm.qtyA.value };
      document.ofrm.qtyA.value = eval(QtyA);  

      if (document.ofrm.qtyB.value > "")
         { QtyB = document.ofrm.qtyB.value };
      document.ofrm.qtyB.value = eval(QtyB);  

      if (document.ofrm.qtyC.value > "")
         { QtyC = document.ofrm.qtyC.value };
      document.ofrm.qtyC.value = eval(QtyC);


      TotA = QtyA * PrcA;
      document.ofrm.totalA.value = leeAmt(eval(TotA));

      TotB = QtyB * PrcB;
      document.ofrm.totalB.value = leeAmt(eval(TotB));

      TotC = QtyC * PrcC;
      document.ofrm.totalC.value = leeAmt(eval(TotC));


      Totamt = 
         eval(TotA) +
         eval(TotB) +
         eval(TotC) ;

      document.ofrm.GrandTotal.value = leeAmt(eval(Totamt));

    } 


    function validNum(theForm)
    {
      var checkOK = "0123456789.,";
      var checkStr = theForm.qtyA.value;
      var allValid = true;
      var validGroups = true;
      var decPoints = 0;
      var allNum = "";
      for (i = 0;  i < checkStr.length;  i++)
      {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
          if (ch == checkOK.charAt(j))
            break;
        if (j == checkOK.length)
        {
          allValid = false;
          break;
        }
        if (ch == ".")
        {
          allNum += ".";
          decPoints++;
        }
        else if (ch == "," && decPoints != 0)
        {
          validGroups = false;
          break;
        }
        else if (ch != ",")
          allNum += ch;
      }
      if (!allValid)
      {
        alert("Please enter only digit characters in the \"Truck Fuel Charge quantity\" field.");
        theForm.qtyA.focus();
        return (false);
      }

      if (decPoints > 1 || !validGroups)
      {
        alert("Please enter a valid number in the \"Truck Fuel Charge quantity\" field.");
        theForm.qtyA.focus();
        return (false);
      }

      var checkOK = "0123456789.,";
      var checkStr = theForm.qtyB.value;
      var allValid = true;
      var validGroups = true;
      var decPoints = 0;
      var allNum = "";
      for (i = 0;  i < checkStr.length;  i++)
      {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
          if (ch == checkOK.charAt(j))
            break;
        if (j == checkOK.length)
        {
          allValid = false;
          break;
        }
        if (ch == ".")
        {
          allNum += ".";
          decPoints++;
        }
        else if (ch == "," && decPoints != 0)
        {
          validGroups = false;
          break;
        }
        else if (ch != ",")
          allNum += ch;
      }
      if (!allValid)
      {
        alert("Please enter only digit characters in the \"contract Labor quantity\" field.");
        theForm.qtyB.focus();
        return (false);
      }

      if (decPoints > 1 || !validGroups)
      {
        alert("Please enter a valid number in the \"contract Labor quantity\" field.");
        theForm.qtyA.focus();
        return (false);
      }

      var checkOK = "0123456789.,";
      var checkStr = theForm.qtyC.value;
      var allValid = true;
      var validGroups = true;
      var decPoints = 0;
      var allNum = "";
      for (i = 0;  i < checkStr.length;  i++)
      {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
          if (ch == checkOK.charAt(j))
            break;
        if (j == checkOK.length)
        {
          allValid = false;
          break;
        }
        if (ch == ".")
        {
          allNum += ".";
          decPoints++;
        }
        else if (ch == "," && decPoints != 0)
        {
          validGroups = false;
          break;
        }
        else if (ch != ",")
          allNum += ch;
      }
      if (!allValid)
      {
        alert("Please enter only digit characters in the \"contract Labor OT quantity\" field.");
        theForm.qtyC.focus();
        return (false);
      }

      if (decPoints > 1 || !validGroups)
      {
        alert("Please enter a valid number in the \"contract Labor OT quantity\" field.");
        theForm.qtyC.focus();
        return (false);
      }


      calculate();
      return (true);
    } 


    //-->
    </script>



    </head>

    <body bgcolor="#FFFFFF">

    <h2>HVAC Estimator</h2>

    <br />


    <form method="POST" action="submitted.html" name="ofrm">
        <table border="0" cellpadding="0" width="550" id="table2" name="ofrm">
            <tr>
                <td width="250" height="31"><b>Item Description</b></td>
                <td align="center" width="100" height="31"><b>Quantity</b></td>
                <td align="right" height="31" width="60"><b>Price </b></td>
                <td align="right" height="31" width="140"><b>Total</b></td>
            </tr>
            <tr>
                <td width="250">Truck & Fuel Surcharge</td>
                <td align="center" width="100">
                <input type="text" name="qtyA" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td>
                <td align="right" width="60"></td>
                <td align="right" width="140">
                <input type="hidden" name="totalA" size="12" tabindex="99" onchange="calculate()"></td>
            </tr>
            <tr>
                <td width="250">Contract Labor</td>
                <td align="center" width="100">
                <input type="text" name="qtyB" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td>
                <td align="right" width="60"></td>
                <td align="right" width="140">
                <input type="hidden" name="totalB" size="12" tabindex="99" onchange="calculate()"></td>
            </tr>
            <tr>
                <td width="250">Contract Labor OT</td>
                <td align="center" width="100">
                <input type="text" name="qtyC" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td>
                <td align="right" width="60"></td>
                <td align="right" width="140">
                <input type="hidden" name="totalC" size="12" tabindex="99" onchange="calculate()"></td>
            </tr>

            <tr>
                <td width="250">&nbsp;</td>
                <td align="center" width="100">&nbsp;</td>
                <td align="right" width="60">&nbsp;</td>
                <td align="right" width="140">&nbsp;</td>
            </tr>
            <tr>
                <td width="250">
                <p align="right"><b>SUB TOTAL:</b></td>
                <td align="center" width="100">&nbsp;</td>
                <td align="right" width="60">&nbsp;</td>
                <td align="right" width="140">$
                <input readonly style="border:0px;" class="totals" name="GrandTotal" size="15" tabindex="99" onchange="calculate()"></td>
            </tr>
            <tr>
                <td width="250">&nbsp;</td>
                <td align="center" width="100">&nbsp;</td>
                <td align="right" width="60">&nbsp;</td>
                <td align="right" width="140">&nbsp;</td>
            </tr>
        </table>
        </form>
    </body>
    </html> 

2 个答案:

答案 0 :(得分:0)

为什么不像以前那样使用<form>

如果您想使用id s,请使用正确的符号:

QtyA = document.getElementById("qtyA").getAttribute("value");

document.getElementById("GrandTotal").setAttribute("value", bizAmt(eval(Totamt)) );

答案 1 :(得分:-1)

我已将此代码转换为您的要求使用

<html>

    <head>


    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>HVAC Estimator</title>
    <style type="text/css">
    .totals
            {
                font-size: .9em;

            }
    </style>

    <script language=javascript>
    <!--//

    function leeAmt(amount) 
    {
      string = "" + amount;
      dec = string.length - string.indexOf('.');
      if (string.indexOf('.') == -1)
      return string + '.00';
      if (dec == 1)
      return string + '00';
      if (dec == 2)
      return string + '0';
      if (dec > 3)
      return string.substring(0,string.length-dec+3);
      return string;
    }



    function calculate()
    {

      QtyA = 0;  QtyB = 0;  QtyC = 0; 
      TotA = 0;  TotB = 0;  TotC = 0;

      PrcA = 65; PrcB = 88; PrcC = 132;



      if (document.getElementById("qtyA").value > "")
         { QtyA = document.getElementById("qtyA").value };
      document.getElementById("qtyA").value = eval(QtyA);  

      if (document.getElementById("qtyB").value > "")
         { QtyB =document.getElementById("qtyB").value };
      document.getElementById("qtyB").value = eval(QtyB);  

      if (document.getElementById("qtyC").value > "")
         { QtyC = document.getElementById("qtyC").value };
      document.getElementById("qtyC").value = eval(QtyC);


      TotA = QtyA * PrcA;
      document.getElementById("totalA").value = leeAmt(eval(TotA));

      TotB = QtyB * PrcB;
      document.getElementById("totalB").value = leeAmt(eval(TotB));

      TotC = QtyC * PrcC;
      document.getElementById("totalC").value = leeAmt(eval(TotC));


      Totamt = 
         eval(TotA) +
         eval(TotB) +
         eval(TotC) ;

      document.getElementById("GrandTotal").value = leeAmt(eval(Totamt));

    } 


    function validNum(theForm)
    {
      var checkOK = "0123456789.,";
      var checkStr = document.getElementById("qtyA").value;
      var allValid = true;
      var validGroups = true;
      var decPoints = 0;
      var allNum = "";
      for (i = 0;  i < checkStr.length;  i++)
      {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
          if (ch == checkOK.charAt(j))
            break;
        if (j == checkOK.length)
        {
          allValid = false;
          break;
        }
        if (ch == ".")
        {
          allNum += ".";
          decPoints++;
        }
        else if (ch == "," && decPoints != 0)
        {
          validGroups = false;
          break;
        }
        else if (ch != ",")
          allNum += ch;
      }
      if (!allValid)
      {
        alert("Please enter only digit characters in the \"Truck Fuel Charge quantity\" field.");
        document.getElementById("qtyA").focus();
        return (false);
      }

      if (decPoints > 1 || !validGroups)
      {
        alert("Please enter a valid number in the \"Truck Fuel Charge quantity\" field.");
        document.getElementById("qtyA").focus();
        return (false);
      }

      var checkOK = "0123456789.,";
      var checkStr =document.getElementById("qtyB").value;
      var allValid = true;
      var validGroups = true;
      var decPoints = 0;
      var allNum = "";
      for (i = 0;  i < checkStr.length;  i++)
      {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
          if (ch == checkOK.charAt(j))
            break;
        if (j == checkOK.length)
        {
          allValid = false;
          break;
        }
        if (ch == ".")
        {
          allNum += ".";
          decPoints++;
        }
        else if (ch == "," && decPoints != 0)
        {
          validGroups = false;
          break;
        }
        else if (ch != ",")
          allNum += ch;
      }
      if (!allValid)
      {
        alert("Please enter only digit characters in the \"contract Labor quantity\" field.");
        document.getElementById("qtyB").focus();
        return (false);
      }

      if (decPoints > 1 || !validGroups)
      {
        alert("Please enter a valid number in the \"contract Labor quantity\" field.");
        theForm.qtyA.focus();
        return (false);
      }

      var checkOK = "0123456789.,";
      var checkStr = document.getElementById("qtyC").value;
      var allValid = true;
      var validGroups = true;
      var decPoints = 0;
      var allNum = "";
      for (i = 0;  i < checkStr.length;  i++)
      {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
          if (ch == checkOK.charAt(j))
            break;
        if (j == checkOK.length)
        {
          allValid = false;
          break;
        }
        if (ch == ".")
        {
          allNum += ".";
          decPoints++;
        }
        else if (ch == "," && decPoints != 0)
        {
          validGroups = false;
          break;
        }
        else if (ch != ",")
          allNum += ch;
      }
      if (!allValid)
      {
        alert("Please enter only digit characters in the \"contract Labor OT quantity\" field.");
        document.getElementById("qtyC").focus();
        return (false);
      }

      if (decPoints > 1 || !validGroups)
      {
        alert("Please enter a valid number in the \"contract Labor OT quantity\" field.");
        document.getElementById("qtyC").focus();
        return (false);
      }


      calculate();
      return (true);
    } 


    //-->
    </script>



    </head>

    <body bgcolor="#FFFFFF">

    <h2>HVAC Estimator</h2>

    <br />


    <form method="POST" action="submitted.html" name="ofrm">
        <table border="0" cellpadding="0" width="550" id="table2" name="ofrm">
            <tr>
                <td width="250" height="31"><b>Item Description</b></td>
                <td align="center" width="100" height="31"><b>Quantity</b></td>
                <td align="right" height="31" width="60"><b>Price </b></td>
                <td align="right" height="31" width="140"><b>Total</b></td>
            </tr>
            <tr>
                <td width="250">Truck & Fuel Surcharge</td>
                <td align="center" width="100">
                <input type="text" name="qtyA" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td>
                <td align="right" width="60"></td>
                <td align="right" width="140">
                <input type="hidden" name="totalA" size="12" tabindex="99" onchange="calculate()"></td>
            </tr>
            <tr>
                <td width="250">Contract Labor</td>
                <td align="center" width="100">
                <input type="text" name="qtyB" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td>
                <td align="right" width="60"></td>
                <td align="right" width="140">
                <input type="hidden" name="totalB" size="12" tabindex="99" onchange="calculate()"></td>
            </tr>
            <tr>
                <td width="250">Contract Labor OT</td>
                <td align="center" width="100">
                <input type="text" name="qtyC" size="5" tabindex="5" onchange="return validNum(document.ofrm)"></td>
                <td align="right" width="60"></td>
                <td align="right" width="140">
                <input type="hidden" name="totalC" size="12" tabindex="99" onchange="calculate()"></td>
            </tr>

            <tr>
                <td width="250">&nbsp;</td>
                <td align="center" width="100">&nbsp;</td>
                <td align="right" width="60">&nbsp;</td>
                <td align="right" width="140">&nbsp;</td>
            </tr>
            <tr>
                <td width="250">
                <p align="right"><b>SUB TOTAL:</b></td>
                <td align="center" width="100">&nbsp;</td>
                <td align="right" width="60">&nbsp;</td>
                <td align="right" width="140">$
                <input readonly style="border:0px;" class="totals" name="GrandTotal" size="15" tabindex="99" onchange="calculate()"></td>
            </tr>
            <tr>
                <td width="250">&nbsp;</td>
                <td align="center" width="100">&nbsp;</td>
                <td align="right" width="60">&nbsp;</td>
                <td align="right" width="140">&nbsp;</td>
            </tr>
        </table>
        </form>
    </body>
    </html>