Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Drop Down 'IF' message box

Avatar

Former Community Member

I have a drop down list of 8 States applicable to our form.  Below the drop down, there is a table of the 8 states and some information that needs to be provided depending on the State selected.  Example, if a Contractor does business in Texas, a Business License is not needed for general business, but is needed if specialty contractor such as HVAC, Plumbing, etc.  I would like to tailor each message to the state requirements, and possibly require some of the table cells depending on the state licensing requirements/selection.

However, I'm not having much luck in even testing one state.  Here is what I have for 'Texas', and basically it gives the message box pop-up no matter what is selected.  I have tried using TX and Texas as the == value, as the drop down is the standard 'State' object from the library and I deleted all but 8 states. 

Here is where I'm at so far, using JavaScript and this is on the change event of the dropdown.  Appreciate any help, thank you.

if (this.rawValue == "Texas")

{

xfa.host.messageBox("If you are a Specialty Contractor in the State of Texas, please enter Business License info in below table", "BUSINESS LICENSE", 3, 1);

}
1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

the rawValue has not been set when the change event occurs, this happens when you exit the dropt down first.

To check the selection during the change event you have to use xfa.event.change.

if (xfa.event.change === "Texas") {

     xfa.host.messageBox("If you are a Specialty Contractor in the State of Texas, please enter Business License info in below table",     "BUSINESS LICENSE", 3, 1);

}

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

the rawValue has not been set when the change event occurs, this happens when you exit the dropt down first.

To check the selection during the change event you have to use xfa.event.change.

if (xfa.event.change === "Texas") {

     xfa.host.messageBox("If you are a Specialty Contractor in the State of Texas, please enter Business License info in below table",     "BUSINESS LICENSE", 3, 1);

}

Avatar

Former Community Member

Perfect, works like a charm, thank you, I'll get there . . . 

What do you recommend as the best way to address all 8 states/conditions?  In VBA I would use select case or possibly nested if, and would like to know the most efficient way to address in javscript.  Thank you again.