cancel
Showing results for 
Search instead for 
Did you mean: 

drop down list changes fields

Former Member
0 Kudos

I want to add some non trivial functions to my forms, so they look fancier.

What i want to do is: -In a drop down list there are to possible choices.

-If I choose A, I hide some fields on the form

If I choose B i hide some other fields, and make some other reappear.

I guess scripts can do this, but I don't know how, can you give me an example? How do I check which option is chosen, to start with?

Thanks,

Peter

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try to use FormCalc instead.

var value = xfa.event.newText

if ( value eq "TERMINATION OF EMPLOYMENT" ) then

NAME_OF_NOU.presence = "invisible"

ADDITIONAL_COMMENT.rawValue= "Termination of Job"

NAM_OF_STH.presence="invisible"

else

NAME_OF_NOU.presence = "visible"

ADDITIONAL_COMMENT.rawValue= " "

NAM_OF_STH.presence="visible"

endif

reward point if it works.

Answers (2)

Answers (2)

Former Member
0 Kudos

My code was:

var value = xfa.event.newText;

if (value == "TERMINATION OF EMPLOYMENt" ) {

NAME_OF_NOU.presence = "invisible";

ADDITIONAL_COMMENT.rawValue= "Termination of Job";

NAM_OF_STH.presence="invisible"; }

else

{

NAME_OF_NOU.presence = "visible";

ADDITIONAL_COMMENT.rawValue= " ";

NAM_OF_STH.presence="visible";

}

The error message: Syntax error near token' { ' on line 3 column 44

I colored the place of error red. But I don't understand why it's not good..

Former Member
0 Kudos

Well, this color thing did not work, the line correctly was:

f (value == "TERMINATION OF EMPLOYMENT" ) {

Former Member
0 Kudos

Problem was script was set to formcalc. With this code, i had to set it to javascript. But on the pdf preview it does not do a thing. Should this work there?

At least syntax is ok

harman_shahi
Contributor
0 Kudos

Hi Peter,

The Preview should work.

I think there may be an issue with the following statement: "var value = xfa.event.newText;"

So, adjust your code as following:

var value = TextField1.rawValue;


if (value == 'correct') {
xfa.host.messageBox("YES");
}
else
{
xfa.host.messageBox("NO");
}

hope this helps.

harman

harman_shahi
Contributor
0 Kudos

Place the following code on the "onChange" event for the DropDown list

//Get the selected value of the dropdown list
var value = xfa.event.newText;

if (value == 'A')
{
	Button1.presence = "invisible"
	Button2.presence = "visible";
}
else
{
	Button2.presence = "invisible"
	Button1.presence = "visible";
}

Code may have some syntax errors, but you get the idea

Hope this helps,

Harman