home *** CD-ROM | disk | FTP | other *** search
/ Chip Hitware 7 A / CHIP_HITWARE_7A.iso / internet / Webmaster / _SETUP.4 / Group3 / tcost.jav < prev    next >
Text File  |  1999-06-26  |  5KB  |  128 lines

  1. <!---BeginTitle--->Total cost - similar to shopping carts<!---BeginJAVHead---><script language="JavaScript">
  2.  
  3. <!-- hide contents from old browsers
  4.  
  5.     var Cost, GST, PST, Grand_Total;
  6.  
  7. function tally()
  8.     {
  9.     Cost = 0;
  10.     if (document.orderform.Item1.checked) {    Cost = Cost + 26.15;    }
  11.     if (document.orderform.Item2.checked) {    Cost = Cost + 26.10;    }
  12.     if (document.orderform.Item3.checked) {    Cost = Cost + 26;        }
  13.     if (document.orderform.Item4.checked) {    Cost = Cost + 26;        }
  14.     if (document.orderform.Item5.checked) {    Cost = Cost + 26.44;    }
  15.     if (document.orderform.Item6.checked) {    Cost = Cost + 26.01;    }
  16.     if (document.orderform.Item7.checked) {    Cost = Cost + 26;        }
  17.     if (document.orderform.Item8.checked) {    Cost = Cost + 26;        }        
  18.        if (document.orderform.Item9.checked) {    Cost = Cost + 25;        }
  19.  
  20.     GST = (Cost * 0.07);
  21.     PST = (Cost * 0.07);
  22.     
  23.     Cost = dollar(Cost);
  24.     GST = dollar(GST); 
  25.     PST = dollar(PST);
  26.     Grand_Total = parseFloat(Cost) + parseFloat(GST) + parseFloat(PST);
  27.     Grand_Total = dollar(Grand_Total);
  28.  
  29.     document.orderform.Total.value = "$" + Cost;
  30.     document.orderform.GST.value = "$" + GST;
  31.     document.orderform.PST.value = "$" + PST;
  32.     document.orderform.GrandTotal.value = "$" + Grand_Total;
  33.     }
  34.  
  35. function dollar (amount)
  36. {
  37.     amount = parseInt(amount * 100);
  38.     amount = parseFloat(amount/100);
  39.     if (((amount) == Math.floor(amount)) && ((amount - Math.floor (amount)) == 0))
  40.     {
  41.         amount = amount + ".00"
  42.         return amount;
  43.     }
  44.     if ( ((amount * 10) - Math.floor(amount * 10)) == 0)
  45.     {
  46.         amount = amount + "0";
  47.         return amount;
  48.     }
  49.     if ( ((amount * 100) - Math.floor(amount * 100)) == 0)
  50.     {
  51.         amount = amount;
  52.         return amount;
  53.     }
  54.     return amount;     
  55. }
  56.  
  57. //--></script><!---BeginJAVBody---><form method="post" name="orderform" action="mailto:you@yourdomain.com">
  58. <table border="0">
  59.     <tr><td colspan="4">
  60. <p><INPUT TYPE="checkbox" Name="Item1" Value="Item1_chosen" onClick="tally()"> Item One ($26.15)
  61. <p><INPUT TYPE="checkbox" Name="Item2" Value="Item2_chosen" onClick="tally()"> Item Two  ($26.10)
  62. <p><INPUT TYPE="checkbox" Name="Item3" Value="Item3_chosen" onClick="tally()"> Item Three  ($26)
  63. <p><INPUT TYPE="checkbox" Name="Item4" Value="Item4_chosen" onClick="tally()"> Item Four  ($26)
  64. <p><INPUT TYPE="checkbox" Name="Item5" Value="Item5_chosen" onClick="tally()"> Item Five  ($26.44)
  65. <p><INPUT TYPE="checkbox" Name="Item6" Value="Item6_chosen" onClick="tally()"> Item Six  ($26.10)
  66. <p><INPUT TYPE="checkbox" Name="Item7" Value="Item7_chosen" onClick="tally()"> Item Seven  ($26)
  67. <p><INPUT TYPE="checkbox" Name="Item8" Value="Item8_chosen" onClick="tally()"> Item Eight  ($26)
  68. <p><INPUT TYPE="checkbox" Name="Item9" Value="Item9_chosen" onClick="tally()"> Item Nine  ($25)
  69.     </td></tr>
  70. <tr>
  71. <td> Total <INPUT TYPE="text" NAME="Total" value="$0" size="7"></td>
  72. <td> Tax (7%) <INPUT TYPE="text" NAME="PST" value="$0"  size="6"></td>
  73. <td> Tax (7%) <INPUT TYPE="text" NAME="GST" value="$0"  size="6"></td>
  74. </tr>
  75. <tr>
  76. <td> Grand Total <INPUT TYPE="text" NAME="GrandTotal" value="$0" size="8"></td>
  77. </tr>
  78.  
  79.     <tr>
  80.       <td>Company Name:</td>
  81.       <td colspan="3"><input type="Text" name="Company" size="35" maxlength="40"></td>
  82.     </tr>
  83.     <tr>
  84.       <td>Contact Name:</td>
  85.       <td colspan="3">First <input type="Text" name="FirstName" size="15"
  86.       maxlength="20"> Last <input type="Text" name="LastName" size="15" maxlength="20"></td>
  87.     </tr>
  88.     <tr>
  89.       <td>Address</td>
  90.       <td><input type="Text" name="Street" size="20" maxlength="40"></td>
  91.     </tr>
  92.     <tr>
  93.       <td>City</td>
  94.       <td><input type="Text" name="City" size="20" maxlength="20"> </td>
  95.       <td>Province/State:</td>
  96.       <td><input type="Text" name="Province" size="20" maxlength="40"></td>
  97.     </tr>
  98.     <tr>
  99.       <td>Country:</td>
  100.       <td><input type="Text" name="Country" size="20" maxlength="20"></td>
  101.       <td>Code:</td>
  102.       <td><input type="Text" name="Code" size="9" maxlength="10"></td>
  103.     </tr>
  104.     <tr>
  105.       <td>Phone:</td>
  106.       <td><input type="Text" name="Area" size="3" maxlength="5"> <input type="Text" name="Phone"
  107.       size="8" maxlength="10"></td>
  108.       <td>Fax:</td>
  109.       <td><input type="Text" name="AreaFax" size="3" maxlength="5"> <input type="Text"
  110.       name="Fax" size="8" maxlength="10"></td>
  111.     </tr>
  112.     <tr>
  113.       <td>Prefered Email Address:</td>
  114.       <td colspan=2><input type="Text" name="Email" size="30" maxlength="30"></td>
  115.     </tr>
  116.           <td colspan="4" height="3"><hr>
  117.           </td>
  118.         </tr>
  119.       </table>
  120.       </td>
  121.       <td align="center">
  122.     <input type="Submit" value="Send Application"><p>
  123.     <input type="RESET" value="Reset Application">
  124.     </td>
  125.     </tr>
  126.   </table>
  127. </form><!--EndJAVBody-->
  128.