Copy link to clipboard
Copied
Hi all,
I need some help please, I'm doing a form were if you buy something over a certain amount it triggers a 24 month payment plan option and if you go over the next amount it triggers a 36 month plan as well. I've written some code using the IF command for the first time, it says there are no errors but when I add an amount a hit the button to run the calcucations it does nothing.
I've attached a screengrab of the form, how the boxes are formatted and the code is worded (below)
var total = this.getField (‘TotalValue’);
var IFCdeposit = this.getField (‘_IFCdepositsum’);
var IFCsum = this.getField (‘_IFCtermsum’);
var IFC24 = this.getField (‘_24IFCmonthly’);
var IFC36 = this.getField (‘_36IFCmonthly’);
if (total.value >= 12000.00) IFCdeposit.value = total.value * 0.50;
var IFCdepositCalc = total.value * 0.50;
IFCdeposit.value = IFCdepositCalc;
IFCsum.value = IFCdepositCalc;
if (IFCsum.value >= 6000.00)
var IFC24Calc = IFCsum.value / 24;
IFC24.value = IFC24Calc;
if (IFCsum.value >= 7500.00)
var IFC36Calc = IFCsum.value / 36;
IFC36.value = IFC36Calc;
Any help would be greatfully recieved, as I'm no coder......
Thanks Simon
Copy link to clipboard
Copied
There are few errors in your script, you have wrong quotes use these "TotalValue" or these 'TotalValue'.
You need to put if statements inside curly brackets like this:
if (total.value >= 12000.00) {
var IFCdepositCalc = total.value * 0.50;
IFCdeposit.value = IFCdepositCalc;
IFCsum.value = IFCdepositCalc;
}
Copy link to clipboard
Copied
sorry all noticed i put the wrong code up, it should be this
var total = this.getField (‘TotalValue’);
var IFCdeposit = this.getField (‘_IFCdepositsum’);
var IFCsum = this.getField (‘_IFCtermsum’);
var IFC24 = this.getField (‘_24IFCmonthly’);
var IFC36 = this.getField (‘_36IFCmonthly’);
if (total.value >= 12000.00)
var IFCdepositCalc = total.value * 0.50;
IFCdeposit.value = IFCdepositCalc;
IFCsum.value = IFCdepositCalc;
if (IFCsum.value >= 6000.00)
var IFC24Calc = IFCsum.value / 24;
IFC24.value = IFC24Calc;
if (IFCsum.value >= 7500.00)
var IFC36Calc = IFCsum.value / 36;
IFC36.value = IFC36Calc;
Copy link to clipboard
Copied
Check the Javascript console for errors (ctrl-j)
Copy link to clipboard
Copied
There are few errors in your script, you have wrong quotes use these "TotalValue" or these 'TotalValue'.
You need to put if statements inside curly brackets like this:
if (total.value >= 12000.00) {
var IFCdepositCalc = total.value * 0.50;
IFCdeposit.value = IFCdepositCalc;
IFCsum.value = IFCdepositCalc;
}
Copy link to clipboard
Copied
thatnks was the ’ to ' that stopped it working cheers