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

Conditional logic with combo boxes and text fields

New Here ,
Sep 28, 2018 Sep 28, 2018

Greetings, all.

I have basically no understanding of JavaScript, so I'm hoping someone might be willing to point me in the right direction to see if I'm asking for impossible feats of PDF form wizardy.

I work with college students in building their schedules of classes for each term.  I'm hoping I might be able to utilize JavaScript so that if a student selects a certain response from a combo box, a weekly schedule grid will block off days/times as potential time conflicts.  (For example, if the user selects A from the combo box, Thursdays from 2:00 to 4:00 are blocked off in the weekly schedule grid.)

This seems a little different from other questions related to conditional logic within PDF forms since I'm not actually asking the users to answer additional questions based on their choices; however, can I adapt the JavaScript to make text elements hidden or visible based on student choices?

If that's possible, would any of you be willing to take pity on me and provide a basic code that I can copy and paste so that I can get headed in the right direction for making this work within my form?  (Again, I'm really a novice at JavaScript, but I'm also capable of catching on to things relatively quickly.)

Please let me know if I'm asking too much of JavaScript or if I can provide any more details about what I'm hoping to accomplish.  I appreciate your consideration.

TOPICS
PDF forms
1.2K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Sep 28, 2018 Sep 28, 2018

Yes, as long as that text is a part of a field... It can be a (read-only) text field, or even a button field.

View solution in original post

Translate
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 ,
Sep 28, 2018 Sep 28, 2018

Do you have a unique text field for each such block? If so, it can be done quite easily. Well, it might be a lot of work, but the code is simple. Let's say you have a text field called "Thurs_2_4" and you want to show it only if "A" or "C" is selected in the "Schedule" drop-down field. You can create a hidden text field and use the following code as its custom calculation script:

var schedule = this.getField("Schedule").valueAsString;

this.getField("Thurs_2_4").display = (schedule=="A" || schedule=="C") ? display.visible : display.hidden;

You can then easily expand it to other fields and other values. Let's say that "Fri_12_2" should only be visible if "B" is selected. Then you add this to the code:

this.getField("Fri_12_2").display = (schedule=="B") ? display.visible : display.hidden;

And so on.

Translate
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
New Here ,
Sep 28, 2018 Sep 28, 2018

Thank you for your quick reply.

Your response sounds like what I'm hoping to find.  Just to make sure that we're on the same page, what I'm looking to display is actual text, not a field to be completed by the student.  Is that still consistent with your helpful response?

Translate
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 ,
Sep 28, 2018 Sep 28, 2018

Yes, as long as that text is a part of a field... It can be a (read-only) text field, or even a button field.

Translate
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
New Here ,
Sep 28, 2018 Sep 28, 2018

Thank you so much.

Translate
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
New Here ,
Sep 28, 2018 Sep 28, 2018
LATEST

This really is magical.  Thank you so much!

Translate
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