400-809-6709
RH98 · 最新动态

ecshop购买数量的加减按钮,加一个减一个代码,商品数量加减代码

来源:瑞恒网络 浏览:
ecshop购买数量的加减按钮,加一个减一个代码,商品数量加减代码

方法一:

1.复制以下JS代码,添加到 js/common.js 的最后


function cart_number(txt_id, type, num)
{     num = num || 1;   
 var txt = document.getElementByIdx_x_x(txt_id);    
var source_num = parseInt(txt.value);   
 if (source_num == 1 && type == '-')   
 {   
 alert('请最少购买一个商品');  
       return;   
 }   
 var to_num       = source_num;    
if (type == '+')   
 {       
 to_num += num;   
 }    
else if (type == '-')   
 {     
   to_num -= num; 
   }    
  txt.value = to_num;  
  showdiv(txt);
 }
 

 

 

2.在flow.dwt中找到购买数量的文本框,在他的前后分别加上

<a href="javascript:cart_number('goods_number_{$goods.rec_id}', '-');">-</a>
<a href="javascript:cart_number('goods_number_{$goods.rec_id}', '+');">+</a>

 

 方法二:

在flow.dwt中找到购买数量的文本框,在他的前后分别加上

<IMG style="PADDING-LEFT: 0px; CURSOR: pointer"
onclick='if (document.getElementByIdx_x("number").value>1){document.getElementByIdx_x("number").value--;}'
src="images/down.gif" >&nbsp;

 <INPUT id=number style="WIDTH: 40px; TEXT-ALIGN: right" maxLength=4
value=1 name=cart_quantity> 


&nbsp;<IMG style="PADDING-RIGHT: 30px; MARGIN: 0px; WIDTH: 25px; CURSOR: pointer" onclick='document.getElementByIdx_x("number").value++;'
src="images/up.gif" >

← 网站建设避免的几大误区
返回动态列表

准备好重塑网站让生意找上门了吗?

免费提供出海网站可行性评估与 AI 排名和 SEO 诊断报告