Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript not running, does nothing

New Here ,
Sep 16, 2024 Sep 16, 2024

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)

Screenshot 2024-09-16 at 11.32.08.jpgScreenshot 2024-09-16 at 11.43.29.jpg

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

TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , PDF , PDF forms
606
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Sep 16, 2024 Sep 16, 2024

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;
}

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 16, 2024 Sep 16, 2024

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 16, 2024 Sep 16, 2024

Check the Javascript console for errors (ctrl-j)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 16, 2024 Sep 16, 2024

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;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 16, 2024 Sep 16, 2024
LATEST

thatnks was the ’ to ' that stopped it working cheers

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines