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.


Moving rows up and down Adobe Javascript.

Community Beginner ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

I have a form that contains a grid filled with rows. These rows pull information from another part of the form based upon if a specific condition is met. If the condition is not met the rows stay hidden. I would like to know if it is possible to move the rows to the highest index point they can go to in the grid if the condition to make them visible is met. This is to avoid "gaps" where rows can be made visible but they arent next to each other. This is mainly designed to improve readability.

TOPICS
JavaScript, PDF forms

Views

93

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 ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

You can move text from row to row.

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
Community Beginner ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

Is there some reference on where I can learn how to do this?

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 ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

Something like this:

this.getField ("field1").value = this.getField ("field2").value;

this.getField ("field2").value = "";

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
Community Beginner ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

I have pasted an example of what I want to happen, hopefully it makes some sense. I am not sure if the "not equals" operator works in adobe.

 

if(this.getField("AnalysisB1").valueAsString == "Deficient")
event.value = "Building Structure";

if(this.getField("AnalysisB1").valueAsString != "Deficient")
if(this.getField("AnalysisB2").valueAsString == "Deficient")
event.value = "Landscaping/Grounds";

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
LEGEND ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

In other words, there is no trick. You move each field to where it needs to go, and repeat for each field. Be sure to do this in the right order, as once you replace a field the old value is gone. 

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
Community Beginner ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

I have pasted an example of what I want to happen, hopefully it makes some sense. I am not sure if the "not equals" operator works in adobe.

 

if(this.getField("AnalysisB1").valueAsString == "Deficient")
event.value = "Building Structure";

if(this.getField("AnalysisB1").valueAsString != "Deficient")
if(this.getField("AnalysisB2").valueAsString == "Deficient")
event.value = "Landscaping/Grounds";

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
LEGEND ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

Well, the code is legal, but it doesn't look as though it can do anything useful. In particular, there is nothing at all to move information between rows. Have you given up that part of the plan? And, if you have, what is the part of the plan which this code is to do?


Essentially, it's not enough to see only the code, we also need to know exactly what you want or expect it to do. AND, one more thing we NEED is to know where you put the code. What field? Which event? Without that info we can't know what you will see....

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
Community Beginner ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

The example from before is placed in a grid field row called "ElementRow1". It is designed to populate the value of the Analysis field if that field is marked deficient. If an Analysis row is marked "Deficient" I always want the topmost free ElementRow to be populated ie. if the first Analysis field marked deficient is the 25th Analysis field then I want that value to still go to "ElementRow1" and so on. There are about 48 element rows and I want to make sure that there is no gaps. I also want ElementRow fields that arent populated at all to remain hidden.

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
LEGEND ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

Well, that needs an awful lot of code. You've seen the code for moving up one field. You have to loop through all the fields in each row you want to move up. You're using terms that we don't quite understand, like "grid field row". Do you mean a row contains only one field? Where are these analysis fields, or is there only one field?

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
Community Beginner ,
Jul 13, 2021 Jul 13, 2021

Copy link to clipboard

Copied

There are a few fields in each row. I just wanted to make it easier by only talking about one field in the row, and I figured the code for each of the other fields would use the same logic. I have included a sanitized version of the form. Basically I want the Analysis string value(if marked deficient) to go to the topmost free ElementRow otherwise I want the ElementRow to remain hidden.

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
Community Beginner ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

Does what I mentioned seem possible to you?

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
LEGEND ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

I wouldn't say it was impossible for an experienced JavaScript programmer to achieve. Unusual and rather outside the normal expectations, but achievable, if time consuming.

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
Community Beginner ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

LATEST

Would that amount of code cause the form to lag?

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