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

Need dropdown fields to populate checkbox (Yes, No)

Guest
Dec 01, 2016 Dec 01, 2016

My customer has a form with a Checkbox field called "WeekendCare" With options "Yes" and "No" 

I have 8 dropdown fields (Weekend open and close times) that will need to be examined to determine whether to populate the yes/no. If ANY of the following 8 dropdown fields have a value of a time in the dropdown (other than the default "Select") - the Weekend Care gets checked "Yes"  - if none have values, then "No" is checked.

The dropdown fields are named:

CenterOpenSaturday

CenterOpenSaturday2

CenterCloseSaturday

CenterCloseSaturday2

CenterOpenSunday

CenterOpenSunday2

CenterCloseSunday

CenterCloseSunday2

Can you help with a javascript for this?

And please let me know which field to place the javascript in... that is confusing sometimes.

Thanks for your help!

TOPICS
Acrobat SDK and JavaScript , Windows
366
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 ,
Dec 02, 2016 Dec 02, 2016
LATEST

Yes, this kind of operation can be quite tricky. I think the best was of doing it is to create a hidden text field and use its calculation event for this task, even if the field itself has nothing to do with it. You can use this code to achieve it:

var dropdowns = [

    "CenterOpenSaturday", "CenterOpenSaturday2", "CenterCloseSaturday", "CenterCloseSaturday2", "CenterOpenSunday", "CenterOpenSunday2", "CenterCloseSunday", "CenterCloseSunday2"

];

var tickBox = false;

for (var i in dropdowns) {

    var f = this.getField(dropdowns);

    if (f.valueAsString!=f.defaultValue) {

        tickBox = true; break;

    }

}

this.getField("WeekendCare").checkThisBox(0, tickBox);

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