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

PDF form and Javascript query

Participant ,
Oct 21, 2024 Oct 21, 2024

I have a PDF form that I need to make a specific set of calulations on.

 

The form has a series of tick boxs that when ticked, add a specific value to their corresponding fields.

(I've managed to do this using Javascript).

 

These fields are then totalled up in another field.

(I've done this using the 'caluculate' feature in PDF forms).

 

This all works OK, however my problem is that I need those values to zero out when those fields are unticked and I cannot figure out how to do this.

TOPICS
JavaScript , Modern Acrobat , PDF , PDF forms
838
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 ,
Oct 21, 2024 Oct 21, 2024

You need to put the commands in a code block (surrounded by curly brackets), first of all. As it stands, only the first line is associated with the if-condition. The second one will always be executed. Replace it with this code:

 

if (event.target.value!="Off") {
	this.getField("CPSR value OUT").value=this.getField("CPSR value IN").value;
	this.getField("CPSR RB value OUT").value=this.getField("CPSR RB value IN").value;
} else {
	this.getField("CPSR value OUT").value="";
	this.getField("CPSR RB value OUT").value="";
}

 

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
Community Expert ,
Oct 21, 2024 Oct 21, 2024

Post your code for the first step.

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
Participant ,
Oct 21, 2024 Oct 21, 2024

if (event.target.value!="Off")

this.getField("CPSR value OUT").value=this.getField("CPSR value IN").value

this.getField("CPSR RB value OUT").value=this.getField("CPSR RB value IN").value;

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 ,
Oct 21, 2024 Oct 21, 2024

You need to put the commands in a code block (surrounded by curly brackets), first of all. As it stands, only the first line is associated with the if-condition. The second one will always be executed. Replace it with this code:

 

if (event.target.value!="Off") {
	this.getField("CPSR value OUT").value=this.getField("CPSR value IN").value;
	this.getField("CPSR RB value OUT").value=this.getField("CPSR RB value IN").value;
} else {
	this.getField("CPSR value OUT").value="";
	this.getField("CPSR RB value OUT").value="";
}

 

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
Participant ,
Oct 29, 2024 Oct 29, 2024
LATEST

Thanks that worked perfectly.

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