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

Force Text in Field based on dropdown choice

Avatar

Level 3

I adapted this from an example provided by pguerett call "sanity-check" (in another thread that I can't seem to locate right now) which performed a similar function based on a checkbox.

I have a drop down menu with a change event to set focus the a text menu IF the dropdown item is changed to "other".

In the text field I have an exit event that "should" give a popup msg then set focus back to the dropdown field, IF the dropdown item is "other" AND the field is null on exit.

However, this is not working as planned.

Any assistance would be greatly appreciated.

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Part of it is getting your "=" and "==" mixed up. One = to assign value, two == to compare a value.

I think the attached does what you need.

I changed your script to:

var newValue = this.boundItem(xfa.event.newText);
if (newValue == "Other")
{
    xfa.host.setFocus(form1.IncidentReport.OtherNature);
}

I think the way it works is that you have to specifically capture value selected from the dropdown, because it's just been selected the value doesn't exist in the field yet...or something like that - someone else here can probably explain it properly!

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Part of it is getting your "=" and "==" mixed up. One = to assign value, two == to compare a value.

I think the attached does what you need.

I changed your script to:

var newValue = this.boundItem(xfa.event.newText);
if (newValue == "Other")
{
    xfa.host.setFocus(form1.IncidentReport.OtherNature);
}

I think the way it works is that you have to specifically capture value selected from the dropdown, because it's just been selected the value doesn't exist in the field yet...or something like that - someone else here can probably explain it properly!

Avatar

Level 3

Thanks for clarifying the "=" / "==" issue.

This works perfectly.  I also added an IF script to the exit event of the drop field to assist in ensuring that "other" was doesn't remain selected if the user leaves the explaination text field blank.

Thanks for the help!