A. jquery 購物車加減按鈕問題
沒反映,你就一步步調試,先在 min 方法內 alert(numm) 看看有沒有值,("#"+num).val(parseInt(numm)-1); 前面 加 $ 符號,這個屬於語法錯誤回,之後看看 一步答步 彈出 值 ,慢慢改
B. jquery問題購物車加減按鈕
因為一個頁面中只能存在一個 id 為 add 的元素,根據你現在的代碼,如果有10行記錄,那就會有10個 id 為 add 的 input。
所以你要把這些 input 的 id 都改為 class,text_box 的值也要根據每次點擊來判斷
<input class="min" name="" type="button" value="-" />
<input class="text_box" name="goodnum" type="text" value="${item.value.quantity }" style="width:25px;" />
<input class="add" name="" type="button" value="+" />
$(".add").click(function() {
// $(this).prev() 就是當前元素的前一個元素,即 text_box
$(this).prev().val(parseInt($(this).prev().val()) + 1);
setTotal();
});
$(".min").click(function() {
// $(this).next() 就是當前元素的下一個元素,即 text_box
$(this).next().val(parseInt($(this).next().val()) - 1);
setTotal();
});
C. jsp如何計算購物車總價
<%
Map<Goods,Integer> map=(Map)session.getAttribute("map");
/*if(map==null){
out.println("購物車為空");
return ;
}*/
Set<Goods> key=map.keySet();
// 計算總金額 sums
double sums=0;
for(Goods g:key){
sums=sums+g.getGPRICE()*map.get(g);
}
session.setAttribute("sums",sums);
%>
最後一專行
<span><%=sums %>元屬</span>
D. 在jsp中如何實現這個效果點擊「-」數量減一,點擊「+」數量加1,就像淘寶購物那樣的,如下圖。
這個一般用JS來實現,大致應該是這樣
<!--js函數大致如下 -->
function del(){
var count = document.getElementById("count").value;
count--;
document.getElementById("count").value = count ;
if(count<=1){
document.getElementById("del0").style.display = block;
document.getElementById("del1").style.display = none;
}
if(count < total){//假定total是庫存量
document.getElementById("add0").style.display = block;
document.getElementById("add1").style.display = none;
}
}
function add(){
//......和del方法類似
}
<!-- 頁面處代碼大致如下 -->
<img id="del1"
src="...." onclick="del()" style="dispaly:block">
<img id="del0"
src="...." style="display:none">
<input type="text" id="count" readonly> 1 </input>
<img id="add1"
src="...." onclick="add()" style="dispaly:block">
<img id="add0"
src="...." style="dispaly:none">
很久沒寫代碼了,估計疏漏不少,不過大致是這樣的思路
E. jquery實現購物車物品加減 沒效果,求解
你選擇器來取錯了,沒取到兩個按鈕:自
注意看,#是 id選擇器,class選擇器是以「.」開頭的。
你的代碼裡面 加減兩個按鈕的 id分別為:add1 和 min1 而它們的class為: add和min
所以正確的做法是
$("#add") ---> $("#add1") 、 $("#min") ---> $("#min1")
或者
$("#add") ---> $(".add") 、 $("#min") ---> $(".min")
有不明白的歡迎追問^_^
F. jsp購物車計算數量的問題!
總計只能是每次改動要更新一次咯。沒次算完小計後,再吧所有小計加起來得總計。
G. jsp購物車修改商品數量的問題
<input type="text" id="count" value="<%=goods.getCount()%>" size="1"/>你每個商品的數量都是這個,頁面出現有多個id="count" 的input域
document.getElementById("count").value;當id是count的input唯一的時候才能取到正確的
<input type="text" id="<%=goods.getProId()%>_count" value="<%=goods.getCount()%>" size="1"/>
數量的Input的id可以換一下讓他變成唯一的,例如 商品id,這樣就唯一了
<a href="javascript:go('<%=goods.getProId()%>')">
<img src="img/changecount.gif" title="修改商品數量" border="0" width="15" height="15" style="position: relative;top:2px;"/>
</a>
每次調用go的時候把input的商品id傳過去,
function go(proId){
var str;
str="changecount.jsp?count=";
str+=document.getElementById(proId+"count").value;
str+="&&";
str+="proId=";
str+="<%=goods.getProId()%>";
window.location=str;
}
這樣應該就可以了,主要是因為你那個Input 的id重復了,
H. 如何用jquery實現購物車加減
直接刪除就是了。不過現在都在賽客寶貝街購物。正品,選擇多。
I. jsp頁面購物車中商品加減後,總價不變
去servlet里做邏輯處理
J. struts中jquery如何實現購物車中多個商品數量的增減
$("#btn").click(function(){
var txtvalue=$("商品數量input").val();
$("商品數量input").val(txtvalue+1);
});
你需要這個?還是對選擇器不熟,只能選到內地一條記錄?容