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

How to take text fields entered by user and sort them least to greatest

New Here ,
Aug 02, 2021 Aug 02, 2021

Copy link to clipboard

Copied

Hi - I am still learning how to write scripts in Adobe Pro DC.   On the left side of my form, it requires a user to enter data.   After I have that data entered, I need it to sort on the right side of the form.   This is more complicated than anything I have ever tried to do.Capture.JPG

 

Is it possible to take values entered in column 19 and sort them least to greatest?   

 

If that is possible -next, is it possible to also pull in data from other columns on that same row?

 

Screenshot of worksheet is attached.   I highlighted the columns I need to have sort on the right side.

 

Thank you for any assistance -

 

 

 

 

 

TOPICS
Create PDFs , JavaScript , PDF forms

Views

300

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 ,
Aug 02, 2021 Aug 02, 2021

Copy link to clipboard

Copied

Yes, this is all possible. The general approach would be:

- Collect the data from the source fields and place the values into an array.

- Sort the array using a simple function and the sort method. See: https://www.w3schools.com/js/js_array_sort.asp

- Iterate over the sorted array and write the values from it, in order, to the target fields.

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 ,
Aug 02, 2021 Aug 02, 2021

Copy link to clipboard

Copied

Oh my goodness thank you for taking time to reply to me.   And for being patient - I'm sure my next question will sound a little ignorant.  I am mostly self-taught, so I may not get the terms right.     

 

Can I directly link the source fields into the array?   So it automatically references fields 19a, 19b, 19c, and so on   (with something like:    get.thisField("19a").value)?   

 

Or is the only way to do this is for me to manually plug in the values?

 

Thanks again - I need all the help I can get.

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 ,
Aug 02, 2021 Aug 02, 2021

Copy link to clipboard

Copied

Ugh I cannot even get my stuff right here.  What I meant was by using ----  this.getField ("19a").value

 

not -  get.thisField   -- sheesh.

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 ,
Aug 03, 2021 Aug 03, 2021

Copy link to clipboard

Copied

LATEST

Put the values in a array and sort the array.

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
Enthusiast ,
Aug 02, 2021 Aug 02, 2021

Copy link to clipboard

Copied

There are no fields on the right side of the form. Where exactly do you intend to write sorted numbers?

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 ,
Aug 03, 2021 Aug 03, 2021

Copy link to clipboard

Copied

I will be creating the fields. The worksheet is in progress. I was asking how to do the sort if possible before I got too much further.

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