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

PDF form and Javascript query

Explorer ,
Oct 21, 2024 Oct 21, 2024

Copy link to clipboard

Copied

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

Views

200

Translate

Translate

Report

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

correct answers 1 Correct answer

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 
...

Votes

Translate

Translate
Community Expert ,
Oct 21, 2024 Oct 21, 2024

Copy link to clipboard

Copied

Post your code for the first step.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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;

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Thanks that worked perfectly.

Votes

Translate

Translate

Report

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