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
BedrockMission!

Learn More

View all

Sign in to view all badges

Show text field based on values of 2 other fields

Avatar

Avatar
Boost 1
Level 1
darrenrichie
Level 1

Like

1 like

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
darrenrichie
Level 1

Like

1 like

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
darrenrichie
Level 1

14-03-2017

Hi

I have some text fields that only need to be filled in if the values in 2 other fields meet certain conditions. One of these fields is a dropdown box the other is a tick box. So the hidden text field will appear if:

  • The dropdown box = VALUE1

                         AND

  • The tick box IS selected

Otherwise the textbox is hidden.

I'm not sure where to run the code as it is based on 2 conditions rather than 1.

Any help would be much appreciated.

Thanks

Accepted Solutions (0)

Answers (4)

Answers (4)

Avatar

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
MinusZero
Level 4

15-03-2017

Hi,

You might need to add code to both the DropDownList and the CheckBox so that it doesnt matter which one is selected last.

Using

DropDownList1

CheckBox1

TextField1

CheckBox1: change (Javascript)

if (this.resolveNode("DropDownList1").rawValue == "Value1" && this.resolveNode("CheckBox1").rawValue == "1") {

  this.resolveNode("TextField1").presence = "visible";

}

else

{

TextField1.presence = "invisible";

}

What it does: When the checkbox is checked (rawValue ==1) AND the dropdownlist's rawValue is Value1, TextField1 will be visible. If either is false, TextField1 is invisible (or hidden if you want to do that). && means both items are resolved. If you use & instead and the first half is true, the second part wont be considered in the code.

You can check and uncheck the checkbox to show and hide the field.

Avatar

Avatar
Boost 5
Level 2
try67
Level 2

Likes

13 likes

Total Posts

120 posts

Correct Reply

1 solution
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Affirm 1
View profile

Avatar
Boost 5
Level 2
try67
Level 2

Likes

13 likes

Total Posts

120 posts

Correct Reply

1 solution
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Affirm 1
View profile
try67
Level 2

29-03-2017

[Question moved to the LiveCycle Designer forum]

Avatar

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
MinusZero
Level 4

28-03-2017

Hi,

I am assuming you mean TextField1 is hidden. Both DropDownLists need a Change event.

Using

DropDownList1

DropDownList2

TextField1

------------------------------------

DropDownList1 change: (javascript)

if ($.boundItem(xfa.event.newText) == "text1" && this.resolveNode("DropDownList2").rawValue == "text2") {

  this.resolveNode("TextField1").presence = "visible"; //show if true

}

else

  this.resolveNode("TextField1").presence = "hidden"; //hide if false

------------------------------------

DropDownList2 change: (javascript)

if (this.resolveNode("DropDownList1").rawValue == "text1" && $.boundItem(xfa.event.newText) == "text2") {

  this.resolveNode("TextField1").presence = "visible"; //show if true

}

else

  this.resolveNode("TextField1").presence = "hidden"; //hide if false

------------------------------------

The DropDownLists (DDL) have list items text1 in DDL and text2 in DDL2. When either is changed the code is run. If the conditions are met (both text1 and text2 selected) then the TextField1 is shown. If either DDL has something else selected, TextField1 will be hidden.

See how this goes.

Avatar

Avatar
Boost 1
Level 1
darrenrichie
Level 1

Like

1 like

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
darrenrichie
Level 1

Like

1 like

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
darrenrichie
Level 1

28-03-2017

Thank you for your reply. I am having trouble getting it to work correctly.

If I change the tick box to another dropdown what would the correct code be?

So dropdown1 = "text1" AND dropdown2 = "text2"

textfield1 = visible

else

textfield2 = hidden.