Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Javascript help to compare fields

Avatar

Former Community Member
Looking for some help with javascript to check values using if/then statements.



I have 3 fields:



JobTitle

RateRange

RateAmount



JobTitle is a drop down with the following list items and corresponding values:



List Item Text Value

Manager 1

Supervisor 2

Rep 3



RateRange is a drop down that gets its value from the JobTitle.I pass the rawValue to pull up the corresponding Rate. Here are the values:



List Item Text Value

$30 - $37 1

$26 - $31 2

$12 - $17 3



This part works perfect. If I choose Manager then the RateRange shows me $30-$37.



So the process is the user has selects the JobTitle and the RateRange auto populates, then they will enter the RateAmount. Once the RateAmount is entered, I want to have a script check to see if the amount entered is between the RateRange amounts. If it is not I want it to change the color of the field. Ive figured out how to change the color, but I cant get any if/then statements to work correctly. I figure its because how the RateRange field is set up.



So Ive tried adding a field that will do the same thing as the RateRange except it will only pull the first value, instead of both values in the range, but Im having problems getting that to work.



Any ideas?



Also, how do you reference the display text of a drop down? I believe the binding value is the rawValue? What do you use to look at the display text value?



Thank you in advance!
0 Replies