Skip to main content
Participant
November 21, 2018
Answered

Building Multiple If Statements to Show a Field or Change Message Text

  • November 21, 2018
  • 1 reply
  • 1018 views

Hi All,

I'm fairly new to javascript. I've been working my way up more complex combinations, but I can't seem to figure this one out. I'm trying to get the results of two sets of radio buttons to determine whether multiple fields are shown and which message comes up when clicking the submit button.

If button 1 = yes and button 2 = yes, I need to show fields 3, 4, 5.

If button 1 = yes and button 2 = no, I need to show field 6.

If button 1 = no and button 2 = no, I don't show any fields.

I've been at this all day and unable to write the script that works. PLEASE Help!

This topic has been closed for replies.
Correct answer try67

Understood on that required piece - thank you!

Field names and values are below, along with the combinations.

"LendingLimit" value = Yes + "LoanAmount" value = UW : Nothing to show

"LendingLimit" value = Yes + "LoanAmount" value = NoUW: Nothing to show

"LendingLimit" value = No + "LoanAmount" value = UW : Show "UW_Verify"

"LendingLimit" value = No + "LoanAmount" value = NoUW: Show "Signature_Text" and "Signature_Box"


OK. I would do it using a hidden text field's custom calculation event, and this code:

this.getField("UW_Verify").display = display.hidden;

this.getField("Signature_Text").display = display.hidden;

this.getField("Signature_Box").display = display.hidden;

var v1 = this.getField("LendingLimit").valueAsString;

var v2 = this.getField("LoanAmount").valueAsString;

if (v1=="No" && v2=="UW") {

    this.getField("UW_Verify").display = display.visible;

}

if (v1=="No" && v2=="NoUW") {

    this.getField("Signature_Text").display = display.visible;

    this.getField("Signature_Box").display = display.visible;

}

1 reply

try67
Community Expert
Community Expert
November 21, 2018

What if one, or both, of the fields don't have any value selected at all?

What if 1 = no and 2 = yes?

Participant
November 21, 2018

Great question! They are both required fields. I wouldn't want any action until both were filled out. Fields 3-6 are all hidden by default. I'm not sure if I should be putting this script in the calculation of each field I want to show or hide, or run it based an a mouse up of field 2.