Need help creating a script to display the maximum value from one field in another field | Community
Skip to main content
September 25, 2020
Solved

Need help creating a script to display the maximum value from one field in another field

  • September 25, 2020
  • 1 reply
  • 1280 views

Greetings,

This is my first post and I am a novice with javascript and form calc, but I have a form with a dynamic, expanding table with a sum field at the end. I've got everything working they way I'd like, but the person I'm developing this for wants to see a field be automatically populated with the maximum value from this field. I'm at a loss and would really appreciate the help. Again, I am new here. Is there a way I can post the form for someone to review? Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mayank_Gandhi

@johnt36490185  You can put the script on an exit event. Loop through the table values and read value of cell-like xfa.resolveNode("MyTable.Row1[" + i + "].txtName").rawValue;

keep the value obtained in the last cell in a variable and check inside the loop if the value in the next cell is bigger replace the current value with a bigger value else keep it same. At the end of loop, the largest value will be in the var.

1 reply

Mayank_Gandhi
Adobe Employee
Mayank_GandhiAdobe EmployeeAccepted solution
Adobe Employee
September 25, 2020

@johnt36490185  You can put the script on an exit event. Loop through the table values and read value of cell-like xfa.resolveNode("MyTable.Row1[" + i + "].txtName").rawValue;

keep the value obtained in the last cell in a variable and check inside the loop if the value in the next cell is bigger replace the current value with a bigger value else keep it same. At the end of loop, the largest value will be in the var.

September 25, 2020
Thanks for the reply, but I'm not able to get this to work. I'm not sure what to replace with MyTable and txtName and I'm wondering about the form integrity because I can't get simple exit script tests to work at all on the last field in the table. Again, please excuse my inexperience. Would it be possible to email you the form?