Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


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

47

Likes

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 ,
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.

Likes

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.

Likes

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.

Likes

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

Copy link to clipboard

Copied

LATEST

Put the values in a array and sort the array.

Likes

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?

Likes

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.

Likes

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