这是我将 zen-cart 用于电子商务网站的情况。
在产品详细信息页面中,颜色和尺寸等产品属性都在下拉菜单中。
要求是当购物者单击“添加到购物车”而不选择属性时,会出现警报,提示选择颜色,这也适用于尺寸。
我的问题当我点击“添加到购物车”时,在我关闭框并单击“添加到购物车”而不选择属性后出现警告框没有任何反应。
这是 jQuery 编码
//#attrib-Size is the id for Size attribute
//#attrib-Color is the id for Color attribute
$("#attrib-Size").change(function(){
$("#for_alert").val(1);
});
$("#attrib-Color").change(function(){
$("#for_alert").val(1);
});
/*Add to cart */
$(".des_buynow_addcart").click(function(){
if($("#for_alert").val() == 1){
$("#for_alert").val(0);
if($("#attrib-Size").val() == 0){
alert ("PLEASE SELECT SIZE");
return false;
}
else if($("#attrib-Color").val() == 0){
alert ("PLEASE SELECT COLOR");
return false;
}
else{
这是 HTML 编码
<input class="des_buynow_addcart" type="image" src="includes/templates/********/buttons/english/addto-cart.png" alt="Add to Cart" title=" Add to Cart "/><br/>
<input type="hidden" value="1" name="for_alert" id="for_alert"/>