If/then statement with hidden fields

Avatar

Avatar

Gene--O

Avatar

Gene--O

Gene--O

03-02-2012

I have a form with a drop-down field that has 3 possible values (Today, Tommorrow, Next Week). Below this drop-down field is text field (TextField10) that needs to be filled out by the user ONLY if "Next Week" is selected in the drop-down. I would like for TextField10 to be hidden unless "Next Week" is selected.

For TextField10, I have "this.presence="hidden" written into the initialize event so it is hidden when the user opens the form. This works.

For the drop-down field, I have:

if (this.rawValue == "Next Week") then TextField10.presence = "visible";

     endif

written into the exit event in FormCalc. I need this in FormCalc because I have many other scripts in the exit event already written in FormCalc and I don't want to have to change all of them. I have checked "Specify Item Values" in the Binding Tab of the drop-down field.

Would someone please tell me what I am doing wrong. TextField10 is hidden, but never appears no matter what I select in the drop-down field.

thank you for your help!

Gene-O

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Jono_Moore

Avatar

Jono_Moore

Jono_Moore

08-02-2012

It may need to be saved as a dynamic form, not sure. Is your test form dynamic?

Answers (8)

Answers (8)

Avatar

Avatar

whyisthisme

Avatar

whyisthisme

whyisthisme

05-02-2012

You can also do this easily in the exit event in formcalc:

if ($ == 3) then

TextField10.presence = "visible"

else TextField10.presence = "hidden"

endif

(assuming Next Week has a specified value of 3)

Avatar

Avatar

Jono_Moore

Avatar

Jono_Moore

Jono_Moore

03-02-2012

The value selected for dropdowns work a little differently. You have to get the new value of the selection and I think you can only use the Change event for this (could be wrong).

Also you're mixing some JavaScript syntax in with your FormCalc.

I added code to hide the field should they make another selection.

JavaScript:

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


if (selection == "Next Week") {

     TextField10.presence = "visible";

}

else {

     TextField10.presence = "hidden";

}

And just tried it in FormCalc:

var selection = this.boundItem(xfa.event.newText)


if (selection eq "Next Week")

then TextField10.presence = "visible"

else TextField10.presence = "hidden"

endif

Avatar

Avatar

JainSa

Avatar

JainSa

JainSa

06-07-2018

Hi ,

May i need one help.!

i was created one Text field and then binding the data .

in Binding Field the User Does not Enter the Value .?

How to show  N/A in created text field.

Avatar

Avatar

dtinglin

Avatar

dtinglin

dtinglin

13-02-2018

Mr. Moore,

I'm new to coding and I have a project I'm working on. I have a button that allows a user to attach a PDF to the form. My script works fine

if (app.viewerVersion < 11) {

    import_pre_11();

} else {

    import_11();

}

but I wanted to know is there a conditional script (If/then) that I can use to validate a hidden field value (If the click action is Cancel then the hidden text value= "" but if the click action is Select then the hidden text value is "File Attached")?  I hope that made sense. I'm using Adobe Pro DC.

Thank you!

Avatar

Avatar

Gene--O

Avatar

Gene--O

Gene--O

08-02-2012

Jono - you are correct! When I saved it as dynamic, it worked. Thanks SOOOOOOO MUCH!

Avatar

Avatar

Gene--O

Avatar

Gene--O

Gene--O

08-02-2012

No, it’s Static.

Lt. Gene Schrieber

Alabama Alcoholic Beverage Control Board

Enforcement District 1

P.O. Box 1755

Florence, Alabama 35631

(256) 764-2435

(256) 766-1793 Fax

www.abc.alabama.gov

"Attitude is a choice"

Avatar

Avatar

Jono_Moore

Avatar

Jono_Moore

Jono_Moore

08-02-2012

Is the form saved as "dynamic"?

Avatar

Avatar

Gene--O

Avatar

Gene--O

Gene--O

08-02-2012

Thanks for the replies!!

If I create a test form, these scripts work perfectly. For some reason, they won't work on the form I need them to.

Any ideas?????

thanks!!!