Expand my Community achievements bar.

SOLVED

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

Avatar

Level 1

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!Screen Shot 2020-09-25 at 10.18.52 AM.png

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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

View solution in original post

4 Replies

Avatar

Correct answer by
Employee Advisor

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

Avatar

Level 1
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?

Avatar

Employee Advisor
@johnt36490185 I will try to create a sample and send back alongwith the form.