Increment button for calculated field

New Here ,
May 24, 2018 May 24, 2018

Copy link to clipboard

Copied

I'm pretty much a novice, but able to get some decent engineering calculation worksheets built.

I have a series of dependent calculations that after some user input calculate the depth of a modular water storage tank. The final depth result field has a calculation script and it set to read-only. I want to add plus/minus increment buttons to allow users to see what the water volume capacity will be if they decrease the depth by the one module (the value is 0.33).

I tried various scripts from forums, but none work. None give an error - they just don't work. I have a feeling because the rest of the calculations on the sheet are dynamic (i.e. if the user changes an input value, everything recalculates), I am not using the correct script. I did try "clearing" any value from the field in question...

Here is the scrip that I have in the button action javascript field (on mouse up):

var x = this.getField("RSD"); // this is the field that is initially calculated that I want to allow users to incrementally change

var y = (x -= 0.33); // decrease field RSD value by 0.33 on mouse up

if(x.value!=”||x.value!=null){x.value=”} // clear value in RSD

if(x.value==”||x.value==null){x.value=y.value} // assign y value to RSD

Or is it that I am missing a command to "write" to field RSD?

Any help/direction will be appreciated.

Thanks!

TOPICS
Acrobat SDK and JavaScript

Views

180

Likes

translate

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
Adobe Community Professional ,
May 24, 2018 May 24, 2018

Copy link to clipboard

Copied

Type ctrl-j and look at the console.

Likes

translate

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 ,
May 25, 2018 May 25, 2018

Copy link to clipboard

Copied

This is the error:

SyntaxError: illegal character

5:Field:Mouse Up

Which is the illegal character in my script?

Likes

translate

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
Most Valuable Participant ,
May 25, 2018 May 25, 2018

Copy link to clipboard

Copied

You can only use "straight" quotes, not curly ones.

Likes

translate

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
Adobe Community Professional ,
May 26, 2018 May 26, 2018

Copy link to clipboard

Copied

MariBogi  wrote

...

var y = (x -= 0.33); // decrease field RSD value by 0.33 on mouse up

...

This will not decrease the value of field RSD.

Likes

translate

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
Engaged ,
May 28, 2018 May 28, 2018

Copy link to clipboard

Copied

One thing for sure, if RSD is automaticcaly caluclated (i.e. in a calculate script), you can't increase or decrease its value by just manipulating the result because the calculate event will fire after your intervention, resuming the value to what it was before.

Either you add an invisible "offset" field that will take part of your calculation and you can change its value with your buttons

Or

instead of a calculate script, you use the combination of a doc-level script called from the validation event of your input fields.  That way, will be able to manipulate the result without a calculate script thats fires everytime you do.

Likes

translate

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