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

Pick lowest Age

Participant ,
Jun 22, 2016 Jun 22, 2016

Hi, i have 9 date fields in "mm/yyyy" format. so i want Pick lowest Age. can u pls help me. thanks..

my form fields.

age of account1

age of account2

age of account3

age of account4

age of account5

age of account6

age of account7

age of account8

age of account9

TOPICS
Acrobat SDK and JavaScript , Windows
684
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 , Jun 24, 2016 Jun 24, 2016

See YoungestDateValues to see the results of 4 different ways to perform the task. Only 3 will provide the correct result.

Translate
Community Expert ,
Jun 22, 2016 Jun 22, 2016

What do you mean by "pick", exactly? Do you want to display the lowest age in a text field?

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 ,
Jun 22, 2016 Jun 22, 2016

hi, yes i want to display the lowest age in a text field. 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
Community Expert ,
Jun 22, 2016 Jun 22, 2016

You can use this code as the custom calculation script of that field:

event.value = Math.min(Number(this.getField("age of account1").value), Number(this.getField("age of account2").value), Number(this.getField("age of account3").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 ,
Jun 22, 2016 Jun 22, 2016

hi, bellow code is correct ?? it's giving some error..

error.JPG

value = Math.min(Number(this.getField("age of account1").value),Number(this.getField("age of account2").value),Number(this.getField("age of account3").value),Number(this.getField("age of account4").value),Number(this.getField("age of account5").value),Number(this.getField("age of account6").value),Number(this.getField("age of account7").value),Number(this.getField("age of account8").value),Number(this.getField("age of account9").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 ,
Jun 22, 2016 Jun 22, 2016

Why did you remove the "event." part at the start?

You're missing one closing parenthesis at the end.

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 ,
Jun 22, 2016 Jun 22, 2016

ohh thanks. now code is working. i have add bellow 3 details but answer is "NaN"

02/2005

01/2000

07/2016

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 ,
Jun 22, 2016 Jun 22, 2016

That's not an age, it's a date. If you want to compare dates it's more complicated.

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 ,
Jun 22, 2016 Jun 22, 2016

The value you are trying find the youngest age is considered string type of variable. The minimum method requires numeric values. The "/" in the value makes it a string. You can either alphabetically sort the data or convert the dates to sequential numbers using the JavaScript Date object.  Have you tried different entry values to see how the age field fills in?

Entering a value of "1/2000" will display as "01/2000" but have a value of "1/2000". This missing leading zero could cause a sort problem.

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 ,
Jun 24, 2016 Jun 24, 2016

See YoungestDateValues to see the results of 4 different ways to perform the task. Only 3 will provide the correct result.

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 ,
Jun 24, 2016 Jun 24, 2016
LATEST

thanks a lot..

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