- <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <htmlxmlns="http://www.w3.org/1999/xhtml">
- <head>
- <metahttp-equiv="Content-Type"content="text/html;charset=UTF-8"/>
- <title>jQuery</title>
- <linkrel="stylesheet"type="text/css"href="style.css"/>
- <scriptsrc="http://www.google.com/jsapi"type="text/javascript"></script>
- <scripttype="text/javascript">
- google.load("jquery","1.2.6");
- </script>
- <scripttype="text/javascript"src="order.js"></script>
- </head>
- <body>
- <tableid="order-table">
- <tr>
- <th>ProductName</th>
- <th>Quantity</th>
- <th>X</th>
- <th>UnitPrice</th>
- <th>=</th>
- <thstyle="text-align:right;">Totals</th>
- </tr>
- <trclass="odd">
- <tdclass="product-title">www.corange.cn<em></em></td>
- <tdclass="num-pallets">
- <inputtype="text"class="num-pallets-input"id="turface-pro-league-num-pallets">
- </input>
- </td>
- <tdclass="times">X</td>
- <tdclass="price-per-pallet">$<span>340</span></td>
- <tdclass="equals">=</td>
- <tdclass="row-total">
- <inputtype="text"class="row-total-input"id="turface-pro-league-row-total"disabled="disabled">
- </input>
- </td>
- </tr>
- <trclass="even">
- <tdclass="product-title"><p>Turface®ProLeagueRed-<em>CalcinedClayTopDressinged</em></p>
- <p> </p></td>
- <tdclass="num-pallets">
- <inputtype="text"class="num-pallets-input"id="turface-pro-league-red-num-pallets">
- </input>
- </td>
- <tdclass="times">X</td>
- <tdclass="price-per-pallet">$<span>455</span></td>
- <tdclass="equals">=</td>
- <tdclass="row-total">
- <inputtype="text"class="row-total-input"id="turface-pro-league-red-row-total"disabled="disabled">
- </input>
- </td>
- </tr>
- <trclass="odd">
- <tdclass="product-title">Turface®QuickDry-<em>CalcinedClayMoistureAbsorbent</em></td>
- <tdclass="num-pallets">
- <inputtype="text"class="num-pallets-input"id="turface-quick-dry-num-pallets">
- </input>
- </td>
- <tdclass="times">X</td>
- <tdclass="price-per-pallet">$<span>100</span></td>
- <tdclass="equals">=</td>
- <tdclass="row-total">
- <inputtype="text"class="row-total-input"id="turface-quick-dry-row-total"disabled="disabled">
- </input>
- </td>
- </tr>
- <trclass="even">
- <tdclass="product-title">Turface®MoundClayRed-<em>VirginRedClay</em></td>
- <tdclass="num-pallets">
- <inputtype="text"class="num-pallets-input"id="turface-mound-clay-red-num-pallets">
- </input>
- </td>
- <tdclass="times">X</td>
- <tdclass="price-per-pallet">$<span>40</span></td>
- <tdclass="equals">=</td>
- <tdclass="row-total">
- <inputtype="text"class="row-total-input"id="turface-mound-clay-red-row-total"disabled="disabled">
- </input>
- </td>
- </tr>
- <trclass="odd">
- <tdclass="product-title">RedInfieldConditioner-<em>VitrifiedClayTopDressing</em></td>
- <tdclass="num-pallets">
- <inputtype="text"class="num-pallets-input"id="diamond-pro-red-num-pallets">
- </input>
- </td>
- <tdclass="times">X</td>
- <tdclass="price-per-pallet">$<span>35</span></td>
- <tdclass="equals">=</td>
- <tdclass="row-total">
- <inputtype="text"class="row-total-input"id="diamond-pro-red-row-total"disabled="disabled">
- </input>
- </td>
- </tr>
- <trclass="even">
- <tdclass="product-title">DryingAgent-<em>CalcinedClayMoistureAbsorbent</em></td>
- <tdclass="num-pallets">
- <inputtype="text"class="num-pallets-input"id="diamond-pro-drying-agent-num-pallets">
- </input>
- </td>
- <tdclass="times">X</td>
- <tdclass="price-per-pallet">$<span>340</span></td>
- <tdclass="equals">=</td>
- <tdclass="row-total">
- <inputtype="text"class="row-total-input"id="diamond-pro-drying-agent-row-total"disabled="disabled">
- </input>
- </td>
- </tr>
- <trclass="odd">
- <tdclass="product-title">Professional-<em>CalcinedClayTopDressing</em></td>
- <tdclass="num-pallets">
- <inputtype="text"class="num-pallets-input"id="diamond-pro-professional-num-pallets">
- </input>
- </td>
- <tdclass="times">X</td>
- <tdclass="price-per-pallet">$<span>75</span></td>
- <tdclass="equals">=</td>
- <tdclass="row-total">
- <inputtype="text"class="row-total-input"id="diamond-pro-professional-row-total"disabled="disabled">
- </input>
- </td>
- </tr>
- <trclass="even">
- <tdclass="product-title">TopDressing-<em>CalcinedClaySoilConditioner</em></td>
- <tdclass="num-pallets">
- <inputtype="text"class="num-pallets-input"id="diamond-pro-top-dressing-num-pallets">
- </input>
- </td>
- <tdclass="times">X</td>
- <tdclass="price-per-pallet">$<span>30</span></td>
- <tdclass="equals">=</td>
- <tdclass="row-total">
- <inputtype="text"class="row-total-input"id="diamond-pro-top-dressing-row-total"disabled="disabled">
- </input>
- </td>
- </tr>
- <tr>
- <tdcolspan="6"style="text-align:right;">ProductSUBTOTAL:
- <inputtype="text"class="total-box"id="product-subtotal"disabled="disabled">
- </input>
- </td>
- </tr>
- </table>
- </body>
- </html>
- functionIsNumeric(sText)
- {
- varValidChars="0123456789.";
- varIsNumber=true;
- varChar;
- for(i=0;i<sText.length&&IsNumber==true;i++)
- {
- Char=sText.charAt(i);
- if(ValidChars.indexOf(Char)==-1)
- {
- IsNumber=false;
- }
- }
- returnIsNumber;
- };
- functioncalcProdSubTotal(){
- varprodSubTotal=0;
- $(".row-total-input").each(function(){
- varvalString=$(this).val()||0;
- prodSubTotal+=parseInt(valString);
- });
- $("#product-subtotal").val(prodSubTotal);
- };
- functioncalcTotalPallets(){
- vartotalPallets=0;
- $(".num-pallets-input").each(function(){
- varthisValue=$(this).val();
- if((IsNumeric(thisValue))&&(thisValue!='')){
- totalPallets+=parseInt(thisValue);
- };
- });
- $("#total-pallets-input").val(totalPallets);
- };
- functioncalcShippingTotal(){
- vartotalPallets=$("#total-pallets-input").val()||0;
- varshippingRate=$("#shipping-rate").text()||0;
- varshippingTotal=totalPallets*shippingRate;
- $("#shipping-subtotal").val(shippingTotal);
- };
- functioncalcOrderTotal(){
- varorderTotal=0;
- varproductSubtotal=$("#product-subtotal").val()||0;
- varshippingSubtotal=$("#shipping-subtotal").val()||0;
- varorderTotal=parseInt(productSubtotal)+parseInt(shippingSubtotal);
- varorderTotalNice="$"+orderTotal;
- $("#order-total").val(orderTotalNice);
- };
- $(function(){
- $('.num-pallets-input').blur(function(){
- var$this=$(this);
- varnumPallets=$this.val();
- varmultiplier=$this
- .parent().parent()
- .find("td.price-per-palletspan")
- .text();
- if((IsNumeric(numPallets))&&(numPallets!='')){
- varrowTotal=numPallets*multiplier;
- $this
- .css("background-color","white")
- .parent().parent()
- .find("td.row-totalinput")
- .val(rowTotal);
- }else{
- $this.css("background-color","#ffdcdc");
- };
- calcProdSubTotal();
- calcTotalPallets();
- calcShippingTotal();
- calcOrderTotal();
- });
- });
- myorder.zip (2.5 KB)