Check Box Java Script won't work unless I open and close form tool

New Here ,
Jan 02, 2019

Copy link to clipboard

Copied

A Java Script Checkbox that makes a field visible or hidden based on the condition is not functioning properly. When first opening the form, the box does nothing. If I click on "Prepare Form" tool and immediately close, the button works as it should. If Adobe is closed and the form is reopened, the checkbox stops working again.

var nHide = event.target.isBoxChecked(0)?display.visible:display.hidden;

this.getField("Flex Line Type").display = nHide;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

512

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

Adobe Community Professional , Jan 03, 2019
Bernd Alheit Adobe Community Professional , Jan 03, 2019
Change the name of the drop down list and it will work.

Likes

Translate

Translate
Jump to answer Jump to answer
Most Valuable Participant ,
Jan 02, 2019

Copy link to clipboard

Copied

Where did you place the code?

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Jan 02, 2019

Copy link to clipboard

Copied

I put in on the Checkbox that I want to trigger the change.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jan 02, 2019

Copy link to clipboard

Copied

As a MouseUp action?

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Jan 02, 2019

Copy link to clipboard

Copied

Correct.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jan 02, 2019

Copy link to clipboard

Copied

Then there's no reason it should launch when the file is opened. It will only launch when you click the field.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Jan 02, 2019

Copy link to clipboard

Copied

That is the problem though.  Nothing happens when I click the field.  I can check and uncheck the box all I want and nothing will happen.  But when I open the "Prepare Form" tool and close it, the checkbox works as it should.  I can click it and the field will appear and uncheck it and the field will disappear.  But if I close the form (after saving) and reopen it, the checkbox does not work anymore and I have to open the "Prepare Form" tool again.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jan 02, 2019

Copy link to clipboard

Copied

Can you share the file with us (via Dropbox, Google Drive, Adobe Cloud, etc.)?

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Jan 02, 2019

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jan 02, 2019

Copy link to clipboard

Copied

What's the field in question?

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jan 02, 2019

Copy link to clipboard

Copied

Never mind, found it (Thermal Oil Flex Lines)... It's working just fine for me.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Jan 03, 2019

Copy link to clipboard

Copied

Change the name of the drop down list and it will work.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
claytonb82801752 AUTHOR LATEST
New Here ,
Jan 03, 2019

Copy link to clipboard

Copied

That is an odd way to make it work, but for some reason that fixed the problem.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Jan 02, 2019

Copy link to clipboard

Copied

If you want that code to trigger when you open the PDF, then you will need to rewrite it as a document level function and then call that function. It is possible that it can be written to be used as both the mouse up and document level function. But you would need to pass the value of the check box to the called function and then change the visibility of the field based on the return value from the function.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Jan 02, 2019

Copy link to clipboard

Copied

I am not sure I understand how to do what you are suggesting.  I am a beginner when it comes to making adobe forms.  The problem I am having is that I have the exact same script in another form with a checkbox and it works just fine.  I previously used an if/then function but that one gave me the same trouble on this form.  There is something about this particular form that is causing problems and I can't figure out what it is.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more