多个input标签同步onchange

来源:互联网 发布:sopcast网络电视成人台 编辑:程序博客网 时间:2024/06/07 06:30

js代码: 

三个input标签,分别为成本价,网点价,用户价,实现任何一个价格更改,都更新备注到备注框里。

这个花了不少时间设置。

 var modifyBy=$('#modifyBy').val();

var costPrice;
var valuec;
function costPriceChange(value){
valuec=value;
modifyBy=$('#modifyBy').val();
var oldCostPrice=$('#oldCostPrice').val().toString();
if(value==oldCostPrice){
costPrice="";
allChange();
return;
}
costPrice='修改了成本价格,修改前价格:'+oldCostPrice;
allChange();
}

var salePrice;
var values;
function salePriceChange(value){
values=value;
modifyBy=$('#modifyBy').val();
var oldSalePrice=$('#oldSalePrice').val().toString();
if(value==oldSalePrice){
salePrice="";
allChange();
return;
}
salePrice='修改了网点价格,修改前价格:'+oldSalePrice;
allChange()
}

var userPrice;
var valueu;
function userPriceChange(value){
valueu=value;
modifyBy=$('#modifyBy').val();
var oldUserPrice=$('#oldUserPrice').val().toString();
if(value==oldUserPrice){
userPrice="";
allChange();
return;
}
userPrice='修改了用户价格,修改前价格:'+oldUserPrice;
allChange()
}


function modifyByChange(){
modifyBy=$('#modifyBy').val();
allChange()
}


function allChange(){
var date=$('#today').val();

$("#remark").val("");
if(salePrice && costPrice && userPrice){
$("#remark").val('【'+modifyBy+','+date+costPrice+";"+salePrice+";"+userPrice+'】');
return;
}else if(salePrice && costPrice){
$("#remark").val('【'+modifyBy+','+date+costPrice+";"+salePrice+'】');
return;
}else if(costPrice && userPrice){
$("#remark").val('【'+modifyBy+','+date+costPrice+";"+userPrice+'】');
return;
}else if(salePrice && userPrice){
$("#remark").val('【'+modifyBy+','+date+salePrice+";"+userPrice+'】');
return;
}else if(salePrice){
$("#remark").val('【'+modifyBy+','+date+salePrice+'】');
return;
}else if(userPrice){
$("#remark").val('【'+modifyBy+','+date+userPrice+'】');
return;
}else if(costPrice){
$("#remark").val('【'+modifyBy+','+date+costPrice+'】');
return;
}
return;
}
原创粉丝点击