• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Check this script (Gilads' script)

Participant ,
Jan 04, 2018 Jan 04, 2018

Copy link to clipboard

Copied

I'm using this script to show/hide a field on a timer, and it works fine, but now I'd like to have the field remain visible if populated (it's a drop down). Here's the script I'm using:

        if (util.printd("",new Date())=="") {

    this.getField("Text16").display=display.visible;

    var timeout = app.setTimeOut("this.getField(\"Text16\").display=display.hidden;", 15000);

} else this.getField("Text16").display=display.hidden;

I have this attached to a popMenu button. Is it possible to continue to use this script but to add a bit to cancel out the timer when Text16 is populated? It'll then go back to hidden when reset or when blank. Thanks guys

TOPICS
Acrobat SDK and JavaScript , Windows

Views

487

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Jan 04, 2018 Jan 04, 2018

You can do this by making the timeout script a little more complicated.  Try this:

var timeout = app.setTimeOut("if(this.getField(\"Text16\").value == \"\") this.getField(\"Text16\").display=display.hidden;", 15000);

And as Try says, the first line code (the if) doesn't do anything, you can delete it.

Votes

Translate

Translate
Community Expert ,
Jan 04, 2018 Jan 04, 2018

Copy link to clipboard

Copied

The first line doesn't make sense. What are you trying to do there?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 04, 2018 Jan 04, 2018

Copy link to clipboard

Copied

I'm sorry, I didn't make it clear. When you originally helped me with this bit of script it was back when the AUF was open for q's and a's. I asked for help to show a field on hide a field on a specific date. Well, I still don't know javascript well enough, but I can play around with it well enough to, at times, to modify a working script. I deleted the date info and the script still worked so I left it in, but I didn't know what I was doing and why. So, the script works to show and hide the field.

But now, I would like to show the field and if I make a selection from the drop down it would stay visible. Keeping the timer command, of course, it would go hidden if the drop down field was blank or on Reset after the allotted time. I played around with a bit of show/hide coding but this time I can't figure it out.

I tried the script Thom provided and it worked (somewhat). The field stayed visible after I made a selection from the drop down. But, not on Reset or clear. It remained visible. I'd like the field to go hidden on reset or clear or blank like it does with the timer script.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 04, 2018 Jan 04, 2018

Copy link to clipboard

Copied

What I'm trying to do is, perform a calculation that this drop down is a part of at times (when needed). If I need it I select to show it and when I don't I hide it because I have too many fields and hiding it makes room because I don't need it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 04, 2018 Jan 04, 2018

Copy link to clipboard

Copied

You can do this by making the timeout script a little more complicated.  Try this:

var timeout = app.setTimeOut("if(this.getField(\"Text16\").value == \"\") this.getField(\"Text16\").display=display.hidden;", 15000);

And as Try says, the first line code (the if) doesn't do anything, you can delete it.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 04, 2018 Jan 04, 2018

Copy link to clipboard

Copied

Thom, thanks for trying to help. The code you provided kinda works but if I make a selection and reset the field the field stays visible. And also when (after) I make a selection and clear the field it still stays visible. It should go hidden.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 04, 2018 Jan 04, 2018

Copy link to clipboard

Copied

The script I provided does exactly what you asked.  Changing the visibility for other actions is a different issue. You've got a somewhat complicated process here.

You do an enormous amount of PDF scripting.  And have been for a very long time now. You really aught to have learned more about scripting than you have. I would suggest you do just that. Spend some time and actually learn about this. Or hire someone. You do enough of this that it would be worthwhile.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 04, 2018 Jan 04, 2018

Copy link to clipboard

Copied

LATEST

You're absolutely right, Thom. I enjoy working with this program and even more so when I can get a feature to work. It's a bit confusing to understand it though. I learn a great deal from these forums and stay interested because of the help I find here and the AUF. Most of the answers to my projects have come from here and I appreciate it. The thing is I wish I had the time to spend learning this stuff. I can say it's not easy to do from books or even spending time on the forums. Javascripting, the terminologies and where each coding goes is a bit daunting to do.

I really haven't done an enormous amount of scripting. Perhaps a bit of features to a field or two. Getting a field to do this or that but I've only managed to complete 3 different projects. I wouldn't say that's an enormous amount of scripting.

Perhaps, there would have been more if it weren't for my other concerns such as work and health. My background is not in computer programming. Not in javascripting. Whatever I know today is self learned by trial and error (mostly errors). I wish I had the time to go back to school and learn this stuff, I'm talking about the time I have left, but I don't have that luxury. But, I'm not trying to do this for a living or business.

Anyway, thank you for your help. You're right. The script you provided does work. All the best to all you guys here. I hope a happy and prosperous New Year.

Votes

Translate

Translate

Report

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