87,989
社区成员
发帖
与我相关
我的任务
分享
<script>
/*配件JS*/
void function(){
var updateAdjunctPrice=function(){
var adjunctPrice=0;
var selected=$$('#goods-adjunct tr').filter(function(tr,index){
return tr.getElement('input[type=checkbox]').checked;
});
selected.each(function(s,i){
adjunctPrice+=s.get('price').toFloat()*s.getElement('input[type=hidden]').value.toFloat();
//alert(s.get('price').toFloat()*s.getElement('input[type=hidden]').value)
});
var price=isNaN(adjunctPrice)?0:adjunctPrice;
$E('#goods-adjunct .price').set('text',priceControl.format(price));
};
var adjunctCheckbox=$ES('#goods-adjunct input[type=checkbox]');
var adjunctText=$ES('#goods-adjunct input[type=text]');
adjunctCheckbox.addEvent('click',function(e){
var prt=this.getParent('tr');
var min_num=prt.getParent('tbody').get('min_num').toInt();
if(isNaN(min_num)||min_num<1)min_num=1;
var _hidden=prt.getElement('input[type=hidden]').set('disabled',!this.checked);
this.checked?prt.setStyle('background','#e9e9e9'):prt.setStyle('background','#fff');
var _text=prt.getElement('input[type=text]');
if(!_text.value||_text.value<min_num){
_hidden.value=_text.value=min_num;
}else{
_hidden.value=_text.value;
}
updateAdjunctPrice();
});
adjunctText.addEvent('keydown',function(e){
if($A(keyCodeFix).include(e.code).length>25)
e.stop();
});
adjunctText.addEvent('keyup',function(e){
var prt=this.getParent('tr');
var min_num=prt.getParent('tbody').get('min_num').toInt();
var max_num=prt.getParent('tbody').get('max_num').toInt();
var _hidden=prt.getElement('input[type=hidden]');
if(isNaN(min_num)||min_num<0){
min_num=0;
};
if(isNaN(max_num)||max_num<0){
max_num=Number.MAX_VALUE;
};
if(this.value){
_hidden.value=this.value=this.value.toInt().limit(min_num,max_num);
}
updateAdjunctPrice();
});
}();
</script>
