Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Making a selection visible when picking from a dropdown

donn44157260
Level 5
Level 5

Good Day All;

I am putting together a form where I have a dropdown that contains 3 choices. When one of these choices is selected from the dropdown, a table becomes visible for the user to complete.

The issue I have is when the user selects from the drop down, the table does not become visible unless the user clicks inside the drop down again.

I have tried a “click and the exit” event and came up with the same issue.

The following is the code I am using. I would appreciate any help with this.

Chomp

if (this.rawValue == "5") {

term_select.presence = "visible";

}

if (this.rawValue != "5") {

term_select.presence = "hidden";

}

if (this.rawValue == "6") {

temp_select.presence = "visible";

}

if (this.rawValue != "6") {

temp_select.presence = "hidden";

}

if (this.rawValue == "7") {

act_select.presence = "visible";

}

if (this.rawValue != "7") {

act_select.presence = "hidden";

}

1 Accepted Solution
Jono_Moore
Correct answer by
Level 10
Level 10

You need to use xfa.event.newText to get the selected value.

On the Change event:

var newValue = this.boundItem(xfa.event.newText);

if (newValue == "5") {

    term_select.presence = "visible";

}

//etc.

View solution in original post

0 Replies
_Bruce_Robertson
Level 10
Level 10

Hi,

I think you wanted the change event, and then use xfa.event.change instead of the this.rawValue, so;

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

    term_select.presence = "visible";

}

if (xfa.event.change != "5") {

    term_select.presence = "hidden";

}

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

    temp_select.presence = "visible";

}

if (xfa.event.change != "6") {

    temp_select.presence = "hidden";

}

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

    act_select.presence = "visible";

}

if (xfa.event.change != "7") {

    act_select.presence = "hidden";

}

You might also want to add "execEvent("change");" in the initialize event if you haven't set the initial state some other way.

Bruce

donn44157260
Level 5
Level 5

Thank you Bruce;

I have tried your suggestion. For some reason when I select from the dropdown nothing happens. I am running the Java script debugger  and there are no errors being displayed. I have also included   execEvent("change"); in the initialize event.

I started from scratch and created a simple form that only has 3 items in the select. I used your example and again, no sub form became visible, no errors in the java debugger.

I used my old code and I still had the same issue of the selection in the dropdown did not match up with the sub form that became visual.

I then used only 2 if statements and again got the same result.

if (this.rawValue == "2") {

temp_appoint.presence = "visible";

}

if (this.rawValue != "2") {

temp_appoint.presence = "hidden";

}

   

For your example, I am using LiveCycle designer version 8.05.2072. Would this have anything to do with it not working?

Chomp

Jono_Moore
Correct answer by
Level 10
Level 10

You need to use xfa.event.newText to get the selected value.

On the Change event:

var newValue = this.boundItem(xfa.event.newText);

if (newValue == "5") {

    term_select.presence = "visible";

}

//etc.

View solution in original post

_Bruce_Robertson
Level 10
Level 10

Hi,

Jono is right in that you can't use this.rawValue in the change event because it has not been set yet, you could write code to update or cancel the change.

Unless you have the "Allow custom text entry" set then xfa.event.newText and xfa.event.change have the same value.

Here is a example doing something similar, https://workspaces.acrobat.com/?d=lJp-9eLLfgr3NVJmoJesYA that might help.

Bruce

donn44157260
Level 5
Level 5

Thak you very much for the example Bruce.

Jen_Sav
Level 2
Level 2

Hello all,

This is great advice and I am thinking I could use this on one of my forms, the only question I would need to know an answer to is if this script could work on a drop down with multiple options that may need to be selected more than once. So the scenario goes we've got 6 activities that our stakeholder can choose from and a table would populate for them to fill in the details i.e. date; $rate etc however we need the end user to be able to duplicate the one activity they've chosen if they want to claim on that activity more than once (which they're entitled to do). Can I use the above script in this scenario? Would I need to change anything in order to make the drop down active multiple times? Would I just need to create a repeated subform (that becomes visible) with a min and max set?

Hopefully this makes sense.

Any help you can provide would be of great assistance.

Thank you.