Skip to main content
Participant
February 28, 2017
Question

I have multiple equations that interconnect within fields

  • February 28, 2017
  • 5 replies
  • 475 views

First off, I am NOT a scripter. I've learned from this Forum (lots of script "lifting") and reading. This is a little more complicated for me than the usual question.

Users are submitting a form in which they will enter a current salary, a maximum they cannot exceed (required field) and then they will either enter a percentage for the increase that calculates the new salary OR they might enter their own "new" salary which cannot exceed the maximum and shouldn't exceed the 5%, but could (there are conditions outside of the form that would allow more than 5%). I have a hidden field that will automatically calculate the new salary if the user inputs the percentage. When it comes to choice, I don't have the option to require them to fill out one field or the other; some may pick percentage and some may chose to enter the new salary themselves.

Is there a way to make both fields "available" to the user (conditional), but exclusively validated. I hope I'm explaining this correctly.

The fields are

PAY1 (current salary)

Percentage

PAY2 (new salary)

POSMax (the required budgeted maximum salary for the position)

Calculation (hidden field with simplified field notation: PAY1*Percentage*.01)

The PAY2 field has value sum "PAY1, calculation" and also a custom validation script:  if (event.value==0) event.value =""; so that nothing shows in the field until the calculation is completed.

The Percentage field also has the custom validation script to keep it blank.

This topic has been closed for replies.

5 replies

DPageRAuthor
Participant
March 2, 2017

Not sure. This is sounding more and more unattainable. The only reason for PAY1 change would be an error entry. It is an static number because it is the current salary. The user knows it or put in the wrong number.

try67
Community Expert
Community Expert
March 2, 2017

I suggest thinking of an alternative way of doing it, like having two

radio-buttons and one text field, where the user can select either manual

entry or automatic calculation, or something like that.

DPageRAuthor
Participant
March 1, 2017

Here's another recap:

User inputs PAY1 (current salary)

If user inputs PERCENTAGE, a hidden field CALCULATE1 calculates: percentage number, by PAY1, by .01 and populates PAY2 (new salary) which has a sum calculation PAY1,

OR

If user inputs PAY2 (new salary), a hidden field CALCULATE2 calculates the percentage number (I haven't figured that calculation out yet) and populates PERCENTAGE (might need a calculation if I can't work it all out in the CALCULATE2 field)

try67
Community Expert
Community Expert
March 2, 2017

And what if the user then goes back and edits PAY1? Which of the fields should be calculated then?

DPageRAuthor
Participant
March 1, 2017

Yes, sir!! Is that possible? And maybe we should say, "...or vice versa?"

try67
Community Expert
Community Expert
March 1, 2017

I think so, but it's quite tricky to implement... Also, you'll need to provide the full details of how the calculations should work.

DPageRAuthor
Participant
March 1, 2017

Sorry. My lack of scripting skills has translated in not explaining it well!

Basically, I need two fields to have calculations. Users pick one or the other and which ever they enter data into would calculate in the one they don't pick. They'll need to fill in at least one of them.

The user has to drive to decision, but they both need to have calculations that are exclusive from each other, yet dependent on the other.

Does that make sense??

You pick one of two fields, I give you a calculation on the one you don't pick. Essentially, both fields need to be dynamic.

try67
Community Expert
Community Expert
March 1, 2017

So both fields are editable (and empty), and if the user enters something into field A then field B gets a calculated value, and vice versa?

try67
Community Expert
Community Expert
March 1, 2017

Sorry, I don't follow your question... Do you mean that if the user fills in the value in one field it clears the other one?