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

Change positive number to Negative

Community Beginner ,
Mar 27, 2016 Mar 27, 2016

Hello,

I am using the SUM function in calculated field to add and subtract values and display the results in a "Total" field.  In order to make the subtraction work, the user has to enter a negative number in the "Losses" field.  I would like to have the user just enter a number and have the field automatically change it to a negative number.  Is there a way to do this, or should I be approaching this in a different way?

Capture.JPG

TOPICS
Acrobat SDK and JavaScript , Windows
4.8K
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

correct answers 1 Correct answer

LEGEND , Mar 27, 2016 Mar 27, 2016

A negative number in a column where the color (sign) is negative would indicate a positive number.

I would perform the calculation using the subtract operator. This can be done in the Simplified or the Custom JavaScript options.

Translate
LEGEND ,
Mar 27, 2016 Mar 27, 2016

You can use a custom validate script to automatically make any positive numbers negative, something like:

// Custom Validate script for text field

// If the entered value when converted to a number is greater than zero...

if (+event.value > 0) {

    // ...multiply it by -1 to convert it to a negative number

    event.value = -1 * event.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 Beginner ,
Mar 27, 2016 Mar 27, 2016

Thank you for your quick response.  You solution would definitely work, but I decided to use the Simplified function in the Calculated tab. Thanks

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
LEGEND ,
Mar 27, 2016 Mar 27, 2016

A negative number in a column where the color (sign) is negative would indicate a positive number.

I would perform the calculation using the subtract operator. This can be done in the Simplified or the Custom JavaScript options.

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 Beginner ,
Mar 27, 2016 Mar 27, 2016

Thank you.  I found a video online that explained how to simply add and subtract fields in the Simplified Java Script option.

Thanks.

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
LEGEND ,
Mar 27, 2016 Mar 27, 2016

OK, but consider what would happen if the user enters a negative number.

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
LEGEND ,
Mar 28, 2016 Mar 28, 2016
LATEST

This a reduction of assigned personnel. Any addition would be listed as a gain in TO & E.

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