日期:2014-05-18 浏览次数:20534 次
<script type="text/javascript"> function jia(ele) { tr = ele.parentNode; while (tr.nodeType != 1 || tr.tagName != "TR") tr = tr.parentNode; num = tr.cells[5].getElementsByTagName("input")[0]; var t = parseInt(num.value, 10); if (isNaN(t)) num.value = 0; else num.value = t + 1; countRow(tr) } function jian(ele) { tr = ele.parentNode; while (tr.nodeType != 1 || tr.tagName != "TR") tr = tr.parentNode; num = tr.cells[5].getElementsByTagName("input")[0]; var t = parseInt(num.value, 10); if (isNaN(t)) num.value = 0; else { if (t < 1) return; num.value = t - 1; } countRow(tr) } function bian(ele) { tr = ele.parentNode; while (tr.nodeType != 1 || tr.tagName != "TR") tr = tr.parentNode; countRow(tr) } function countRow(row) { price = parseFloat(row.cells[3].innerHTML); if (isNaN(price)) { row.cells[6].innerHTML = "0" return; } num = row.cells[5].getElementsByTagName("input")[0]; t = parseInt(num.value, 10); if (isNaN(t)) t = 0; row.cells[6].innerHTML = roundPrice(price * t); CountAll(); } function CountAll() { var total = 0; table = document.getElementById('<%=GridView1.ClientID %>'); if (table.rows.length < 3) return; for (i = 1; i < table.rows.length; i++) { p = parseFloat(table.rows[i].cells[6].innerHTML); if (isNaN(p)) p = 0; total += p; } document.getElementById('<%=TotalPrice.ClientID %>').innerHTML = roundPrice(total); } function roundPrice(x) { return Math.round(x * 100) / 100; } </script> <body> <td> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductCode" Width="1052px" onrowdeleting="GridView1_RowDeleting" CssClass="No" onrowdatabound="GridView1_RowDataBound" > <Columns> <asp:BoundField DataField="ProductCode" HeaderText="商品编号" > </asp:BoundField> <asp:ImageField DataAlternateTextField="ProImage" DataImageUrlField="ProImage" DataImageUrlFormatString="../UploadFile/img/{0}" HeaderText="商品图片"> </asp:ImageField> <asp:BoundField DataField="ProductName" HeaderText="商品名称" /> <asp:TemplateField HeaderText="价格"> <ItemTemplate> <%#Eval("MallPrice") %> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Intergral" HeaderText="赠送积分" /> <asp:TemplateField HeaderText="商品数量"> <ItemTemplate>