Hello,
Is there a way to change an objects presence (either a field or a subhead) based on the entered amount range in a numeric field?
For example:
-The numeric field amount entered is a range between 1 and 49,999, then "Signature Subhead 1" appears.
-The numeric field amount entered is a range between 50,000 and 250,000, then "Signature Subhead 2" appears.
Etc.
Any advice for this script would be appreciated.
Thanks!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Try something like this JavaScript in the exit event of your numeric field (you will probably have to change the name of your form objects, SignatureSubhead1 and SignatureSubhead2)
switch (true)
{
case this.rawValue >= 1 && this.rawValue <= 49999:
SignatureSubhead1.presence = "visible";
SignatureSubhead2.presence = "hidden";
break;
case this.rawValue >= 50000 && this.rawValue <= 250000:
SignatureSubhead1.presence = "hidden";
SignatureSubhead2.presence = "visible";
break;
default:
SignatureSubhead1.presence = "hidden";
SignatureSubhead2.presence = "hidden";
}
Regards
Bruce
Views
Replies
Total Likes
Hi,
Try something like this JavaScript in the exit event of your numeric field (you will probably have to change the name of your form objects, SignatureSubhead1 and SignatureSubhead2)
switch (true)
{
case this.rawValue >= 1 && this.rawValue <= 49999:
SignatureSubhead1.presence = "visible";
SignatureSubhead2.presence = "hidden";
break;
case this.rawValue >= 50000 && this.rawValue <= 250000:
SignatureSubhead1.presence = "hidden";
SignatureSubhead2.presence = "visible";
break;
default:
SignatureSubhead1.presence = "hidden";
SignatureSubhead2.presence = "hidden";
}
Regards
Bruce
Views
Replies
Total Likes
Hi Bruce,
Your solution worked perfectly. If I was to expand the ranges (let's say to three ranges), would I just have to add another "case this" logic section such as this?
switch (true)
{
case this.rawValue >= 1 && this.rawValue <= 49999:
SignatureSubhead1.presence = "visible";
SignatureSubhead2.presence = "hidden";
SignatureSubhead3.presence = "hidden";
break;
case this.rawValue >= 50000 && this.rawValue <= 249999:
SignatureSubhead1.presence = "hidden";
SignatureSubhead2.presence = "visible";
SignatureSubhead3.presence = "hidden";
break;
case this.rawValue >= 250000 && this.rawValue <= 500000:
SignatureSubhead1.presence = "hidden";
SignatureSubhead2.presence = "hidden";
SignatureSubhead3.presence = "visible";
break;
default:
SignatureSubhead1.presence = "hidden";
SignatureSubhead2.presence = "hidden";
SignatureSubhead3.presence = "hidden";
}
Appreciated,
Eric
Views
Replies
Total Likes
Hi,
Exactly, this is the advantage of using a switch statement as opposed to series of if statements, this way should be easier to extend.
Good luck
Bruce
Views
Replies
Total Likes