需求是折數"請用%數邏輯更改公式並加上%->請用%off的概念
例如原本的80->新的20%off
function discount_price(L_price) {
for (var i = 1 ; i <= 10 ; i++) {
var price_i = "Price" + i;
var price = Number(document.getElementById(price_i).value);
var L_price_i = "Ltem_price" + i;
var L_price = Number(document.getElementById(L_price_i).value);
var discount_i = "Discount" + i;
var d_price = "";
d_price = Math.round((L_price/price) * 10000 * 10000 / 10000);
if (L_price){
document.getElementById(discount_i).value = d_price / 100 * 10000 / 10000;
}
}
}
目前在語法上是這樣 請問如何修改
小弟沒這方面的經驗 請大大指教
document.getElementById(discount_i).value = d_price / 100 * 10000 / 10000;
改成
document.getElementById(discount_i).value = 100-(d_price / 100 * 10000 / 10000)+"%";
大大再請教一個問題
各類別售價"折扣公式請更改為7折
switch (type) {
case 'K6':
// 拿company去比對ARR如果成功
if (AtoEArr.indexOf(company) !== -1) {
final_price = L_money * 0.85 * 100000 / 100000;
} if (BtoW.indexOf(company) !== -1) {
final_price = L_money;
} if (YtoZ.indexOf(company) !== -1 ) {
final_price = L_money;
}
break;
case 'K9':
if (AtoEArr.indexOf(company) !== -1) {
final_price = L_money * 0.85 * 100000 / 100000;
} if (BtoW.indexOf(company) !== -1) {
final_price = L_money;
} if (YtoZ.indexOf(company) !== -1 ) {
final_price = L_money;
}
break;
case 'K3':
if (AtoEArr.indexOf(company) !== -1) {
final_price = L_money * 0.7 * 100000 / 100000;
} if (BtoW.indexOf(company) !== -1) {
final_price = L_money;
} if (YtoZ.indexOf(company) !== -1 ) {
final_price = L_money * 0.9 * 100000 / 100000;
}
break;
case 'KF':
if (AtoEArr.indexOf(company) !== -1) {
final_price = L_money * 0.8 * 100000 / 100000;
} if (BtoW.indexOf(company) !== -1) {
final_price = L_money;
} if (YtoZ.indexOf(company) !== -1 ) {
final_price = L_money * 0.8 * 100000 / 100000;
}
break;
case 'KM':
if (AtoEArr.indexOf(company) !== -1) {
final_price = L_money * 0.85 * 100000 / 100000;
} if (BtoW.indexOf(company) !== -1) {
final_price = L_money;
} if (YtoZ.indexOf(company) !== -1 ) {
final_price = L_money;
}
break;
default:
}
if (L_money) {
document.getElementById(price_i).value = final_price;
}
}
}
function discount_price(L_price) {
for (var i = 1 ; i <= 10 ; i++) {
var price_i = "Price" + i;
var price = Number(document.getElementById(price_i).value);
var L_price_i = "Ltem_price" + i;
var L_price = Number(document.getElementById(L_price_i).value);
var discount_i = "Discount" + i;
var d_price = "";
d_price = Math.round((L_price/price) * 10000 * 10000 / 10000);
if (L_price){
document.getElementById(discount_i).value = 100-(d_price / 100 * 10000 / 10000)+"%";
}
}
}
是需要修改甚麼
我覺得,這已經跟程式無關了。已經是數學問題了。
我解決了 找到地方修改
感謝