我正在寻找应该以这种方式工作的计算器插件(适用于Wordpress)或脚本:
应该只有一个字段,用户可以输入我的产品编号(Instagram喜欢)。并且取决于成本的变化。
我得到了不同喜欢的价格的各种价格。例如:
如果用户输入数字5555,则应自动计算5555 * 0.0009
请你帮助我吗?
答案 0 :(得分:4)
var likes = document.getElementById("your id for likes").value;
var costPerLike;
if(likes <= 10000){costPerLike = 0.0009} else if(likes >= 10001 && likes <= 50000){costPerLike = 0.0008}
我认为这应该有助于你朝着正确的方向前进。
你可能想在onchange或onsubmit事件中使用它。
答案 1 :(得分:1)
你可以使用这个。
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<button (click)="dialogOpen = true">Open Dialog</button>
<p>Status: {{ status }}</p>
<kendo-dialog title="Action required" (close)="onDecline()" *ngIf="dialogOpen">
<p>Do you accept?</p>
<kendo-dialog-actions>
<button kendoButton (click)="onAccept()">Yes</button>
<button kendoButton (click)="onDecline()">No</button>
</kendo-dialog-actions>
</kendo-dialog>
`
})
export class AppComponent {
public status = "not open";
dialogOpen : boolean = false;
public onAccept() { this.status = "accepted"; this.closeDialog(); }
public onDecline() { this.status = "declined"; this.closeDialog(); }
private closeDialog() {
this.dialogOpen = false;
}
}
&#13;
function priceCalculation(a){
if(a <= 10000){
return 0.0009;
}else if(a >= 10001 && a <= 25000 ){
return 0.0008;
}else if(a >= 25001 && a <= 50000 ){
return 0.0007;
}else if(a >= 50001 && a <= 100000 ){
return 0.0005;
}else{
return 0.0004;
}
}
$('#likecount').keyup(function(){
var price = priceCalculation($(this).val());
console.log(price)
var total = $(this).val() * price;
$('#output').text(total.toFixed(4));
});
&#13;