亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

購物車勾選購買商品,計算總計,產生錯誤的結果,請各位大神指點迷津!

購物車勾選購買商品,計算總計,產生錯誤的結果,請各位大神指點迷津!

yuantongxin 2016-05-11 14:26:04
<%@?page?contentType="text/html;?charset=utf-8"?language="java"?import="java.sql.*"?errorPage=""?%> <%@?taglib?uri="http://java.sun.com/jsp/jstl/core"?prefix="c"?%><%--導入JSTL標簽庫?--%> <%--?<jsp:include?page="/NextOrderServlet"></jsp:include>導入下訂單控制器?--%> <% String?path?=?request.getContextPath(); String?basePath?=?request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!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>購物車</title> <link?rel="stylesheet"?type="text/css"?href="style/Books.css"/> <script?type="text/javascript"> var?xhr; ????? function?ChooseToBuyAjax(){ ????? xhr?=?new?XMLHttpRequest();//初始化 xhr.open("POST",?"ChooseToBuyAjaxServlet",?true);//用異步方式發送post請求 xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");//處理中文亂碼問題 xhr.send("Bid="+document.getElementById("Bid").value+"&Num="?+?document.getElementById("Num").value+"&Price="+document.getElementById("Price").value);//向服務器發送數據 xhr.onreadystatechange?=?function()?{//狀態改變時調用服務器響應的數據修改頁面 if?(xhr.readyState?==?4?&&?xhr.status?==?200)?{ document.getElementById("total").innerHTML?=?xhr.responseText;//獲取服務器響應的文本 } }; ????? }; </script> </head> <body> <div?name="title"> <table?align="center"> ???? <tr> ???????? <td?colspan="4"><img?id="logo"?src="image/logo.png"/></td> ?????????? <td?colspan="4"><h1>圖書你的神話</h1></td> ????????? <c:choose> ?????????? <c:when?test="${UNAME!=null}"><%--用戶名存在?--%> ?????????? <td><a?href="Pensonal.jsp">Hi,${UNAME}</a></td> ?????????? <td><a?href="">[退出]</a></td> ?????????? </c:when> ?????????? <c:otherwise><%--用戶名不存在?--%> ?????????? <td><a?href="login.jsp"><input?type="submit"?value="登錄"?class="submit"/></a></td> ?????????? <td><a?href="NewUser.jsp"><input?type="submit"?value="注冊"?class="submit"/></a></td> ?????????? </c:otherwise> ?????????? </c:choose> ?????? </tr> ????</table> </div> <div> <h2>購物車詳情</h2> <table?align="center"> <tr> <th><input?type="checkbox"/>全選</th> <th>圖書封面</th> <th>圖書名</th> <th>單價(元)</th> <th>數量</th> <th>金額(元)</th> <th>操作</th> </tr> ???? <c:choose> ???? <c:when?test="${SHOWMINUTES!=null}"><%--顯示訂單詳情列表存在?--%> ???? <c:forEach?var="m"?items="${SHOWMINUTES}"><%--遍歷顯示訂單詳情列表?--%> ???? <tr> ???????? <td><input?type="checkbox"?id="Bid"?name="Bid"?value="${m.getBid()}"?onchange="ChooseToBuyAjax()"/></td> ???????? <td><img?src="${m.getId()}"?width="100px"?height="100px"/></td> ???????? <td>${m.getOid()}</td> ???????? <td>¥${m.getPrice()/m.getNum()}</td> ????????????<td><input?type="text"?id="Num"?name="Num"?value="${m.getNum()}"/></td> ????????????<td><input?type="text"?id="Price"?name="Price"?value="${m.getPrice()}"/></td> ????????????<td> ???????????? <dl> ???????????? <dt>移入收藏</dt> ???????????? <dd>刪除</dd> ???????????? </dl> ????????????</td> ???????? </tr> ???? </c:forEach> ???? </c:when> ???? <c:otherwise><%--顯示訂單詳情列表不存在?--%> ???? ???? </c:otherwise> ???? </c:choose> ????????<!--一頁十條記錄--> ????????<tr> ???????? <td?colspan="6"?align="right"> ????????????<a?href="#"> ???????????? 總計(不含運費): ???????????? <span?id="total">¥0.00</sapn> ????????????</a> ????????????</td> ????????</tr> ????</table> </div> <div?id="end"> <hr?color="#993300"/> <p?align="center">版權所有&copy;工作室</p> <p?align="center">手機版下載:<a?href="#">Android</a>|<a?href="#">Iphone</a></p> <p?align="center">聯系我們:1383838438</p> </div> </body> </html>問題出現在最后一張圖片上,我要買3本書,按各自的單價計算,總計應為:106.5但現在顯示的計算結果是:買了12本高等數學的價格這個頁面的共功能是:點擊每行的復選框,把每行的金額累加,也就是把所以選中復選框的金額求和,顯示在總計
查看完整描述

1 回答

?
昵稱不可以為空0

TA貢獻4條經驗 獲得超0個贊

解決了嗎?

查看完整回答
反對 回復 2016-06-15
  • 1 回答
  • 1 關注
  • 1873 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號