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

Help with Java

New Here ,
Nov 19, 2019 Nov 19, 2019

Copy link to clipboard

Copied

Hi Guys,

 

I am very new to Java Coding and trying to do as much as I can without help.

I have a form with multiple dropdown boxes, each dropdown has 5 options Strongly Agree, Agree, Neither Agree or Disagree, Disagree and Strongly Disagree. Each option is assigned a number between 0-4. All the boxes are then added to give a score which will give a discription. The problem I have is that the form is adding each field as I go and taking time. I want to add a button that you press when the drop down boxes have been completed to perform the calculation.

The field the calculation will go in is called "Your_Risk_Score". Can some one help me with the last bit of my script to get the box.

 

This is what I have so far:-

var v1 = Number(this.getField("ATR1").valueAsString);

var v2 = Number(this.getField("ATR3").valueAsString);

var v3 = Number(this.getField("ATR5").valueAsString);

var v4 = Number(this.getField("ATR7").valueAsString);

var v5 = Number(this.getField("ATR9").valueAsString);

var v6 = Number(this.getField("ATR11").valueAsString);

var v7 = Number(this.getField("ATR13").valueAsString);

var v8 = Number(this.getField("ATR15").valueAsString);

var v9 = Number(this.getField("ATR17").valueAsString);

var v10 = Number(this.getField("ATR19").valueAsString);

var v11 = Number(this.getField("ATR21").valueAsString);

var v12 = Number(this.getField("ATR23").valueAsString);

event.value = v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12;

TOPICS
Acrobat SDK and JavaScript

Views

354

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 , Nov 19, 2019 Nov 19, 2019

First of all, this is not Java code. It's JavaScript. Similar names, but very different languages.

So you want this code to execute when a button is clicked? If so, just change the last line to:

 

this.getField("Your_Risk_Score").value = v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12;

 

And of course move it from the field's Calculation event to the Mouse Up event of the button field.

Votes

Translate

Translate
Community Expert ,
Nov 19, 2019 Nov 19, 2019

Copy link to clipboard

Copied

First of all, this is not Java code. It's JavaScript. Similar names, but very different languages.

So you want this code to execute when a button is clicked? If so, just change the last line to:

 

this.getField("Your_Risk_Score").value = v1+v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12;

 

And of course move it from the field's Calculation event to the Mouse Up event of the button field.

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
New Here ,
Nov 19, 2019 Nov 19, 2019

Copy link to clipboard

Copied

LATEST

Thanks for the help. I have been looking too hard I think. Much appreciated!!

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