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

AutoFill checkbox from a drop - down - list

Community Beginner ,
Dec 23, 2019 Dec 23, 2019

Hi,

I have a problem. I wrote  this java - script to autofill diffrent checkboxes from a selection in a Drop - Down - List, but it doesnt work. Can somebody help me pls? Thanks for helping!

 

if (event.value == "Modul Ernährung und Gewichtsreduktion") {
this.getField("Check 0").checkThisBox(0,true);
this.getField("Check 4").checkThisBox(0,true);
this.getField("Check 5").checkThisBox(0,true);
this.getField("Check 7").checkThisBox(0,true);
this.getField("Check 15").checkThisBox(0,true);
}
else {
this.getField("Check 0").checkThisBox(0,fals);
this.getField("Check 4").checkThisBox(0,fals);
this.getField("Check 5").checkThisBox(0,fals);
this.getField("Check 7").checkThisBox(0,fals);
this.getField("Check 15").checkThisBox(0,fals);
}

if (event.value == "Modul Bewegung") {
this.getField("Check 0").checkThisBox(0,true);
this.getField("Check 4").checkThisBox(0,true);
this.getField("Check 16").checkThisBox(0,true);
this.getField("Check 81").checkThisBox(0,true);
}
else {
this.getField("Check 0").checkThisBox(0,fals);
this.getField("Check 4").checkThisBox(0,fals);
this.getField("Check 16").checkThisBox(0,fals);
this.getField("Check 81").checkThisBox(0,fals);
}

if (event.value == "Modul entspanntes Leben") {
this.getField("Check 3").checkThisBox(0,true);
this.getField("Check 6").checkThisBox(0,true);
this.getField("Check 9").checkThisBox(0,true);
}
else {
this.getField("Check 3").checkThisBox(0,fals);
this.getField("Check 6").checkThisBox(0,fals);
this.getField("Check 9").checkThisBox(0,fals);
}

 

 

TOPICS
Acrobat SDK and JavaScript
955
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

correct answers 1 Correct answer

Community Expert , Dec 23, 2019 Dec 23, 2019

The second if resets the checkbox.

 

Try this:

this.getField("Check 0").checkThisBox(0,false);
this.getField("Check 4").checkThisBox(0,false);
this.getField("Check 5").checkThisBox(0,false);
this.getField("Check 7").checkThisBox(0,false);
this.getField("Check 15").checkThisBox(0,false);
this.getField("Check 16").checkThisBox(0,false);
this.getField("Check 81").checkThisBox(0,false);
this.getField("Check 3").checkThisBox(0,false);
this.getField("Check 6").checkThisBox(0,false);
this.getField("Che
...
Translate
Community Expert ,
Dec 23, 2019 Dec 23, 2019

You must use false, not fals

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 Beginner ,
Dec 23, 2019 Dec 23, 2019

Hallo Bernd,

 

danke für deine Antwort. Weisst du warum ich beim Auswählen vom Modul Ernährung und Gewichtsreduktion kein Häckchen in der Checkbox 0 bekomme? Dies erscheint nur, wenn ich das zweite Modul auswähle? Kommt dass daher, dass sich hier einzelne Kästchen in den Modulen wiederholen?

 

Besten Dank für deine Antwort

HG

 

if (event.value == "Modul Ernährung und Gewichtsreduktion") {
this.getField("Check 0").checkThisBox(0,true);
this.getField("Check 4").checkThisBox(0,true);
this.getField("Check 5").checkThisBox(0,true);
this.getField("Check 7").checkThisBox(0,true);
this.getField("Check 15").checkThisBox(0,true);
}
else {
this.getField("Check 0").checkThisBox(0,false);
this.getField("Check 4").checkThisBox(0,false);
this.getField("Check 5").checkThisBox(0,false);
this.getField("Check 7").checkThisBox(0,false);
this.getField("Check 15").checkThisBox(0,false);
}

if (event.value == "Modul Bewegung") {
this.getField("Check 0").checkThisBox(0,true);
this.getField("Check 4").checkThisBox(0,true);
this.getField("Check 16").checkThisBox(0,true);
this.getField("Check 81").checkThisBox(0,true);
}
else {
this.getField("Check 0").checkThisBox(0,false);
this.getField("Check 4").checkThisBox(0,false);
this.getField("Check 16").checkThisBox(0,false);
this.getField("Check 81").checkThisBox(0,false);
}

if (event.value == "Modul entspanntes Leben") {
this.getField("Check 3").checkThisBox(0,true);
this.getField("Check 6").checkThisBox(0,true);
this.getField("Check 9").checkThisBox(0,true);
}
else {
this.getField("Check 3").checkThisBox(0,false);
this.getField("Check 6").checkThisBox(0,false);
this.getField("Check 9").checkThisBox(0,false);
}

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 23, 2019 Dec 23, 2019

The second if resets the checkbox.

 

Try this:

this.getField("Check 0").checkThisBox(0,false);
this.getField("Check 4").checkThisBox(0,false);
this.getField("Check 5").checkThisBox(0,false);
this.getField("Check 7").checkThisBox(0,false);
this.getField("Check 15").checkThisBox(0,false);
this.getField("Check 16").checkThisBox(0,false);
this.getField("Check 81").checkThisBox(0,false);
this.getField("Check 3").checkThisBox(0,false);
this.getField("Check 6").checkThisBox(0,false);
this.getField("Check 9").checkThisBox(0,false);

if (event.value == "Modul Ernährung und Gewichtsreduktion") {
this.getField("Check 0").checkThisBox(0,true);
this.getField("Check 4").checkThisBox(0,true);
this.getField("Check 5").checkThisBox(0,true);
this.getField("Check 7").checkThisBox(0,true);
this.getField("Check 15").checkThisBox(0,true);
}

if (event.value == "Modul Bewegung") {
this.getField("Check 0").checkThisBox(0,true);
this.getField("Check 4").checkThisBox(0,true);
this.getField("Check 16").checkThisBox(0,true);
this.getField("Check 81").checkThisBox(0,true);
}

if (event.value == "Modul entspanntes Leben") {
this.getField("Check 3").checkThisBox(0,true);
this.getField("Check 6").checkThisBox(0,true);
this.getField("Check 9").checkThisBox(0,true);
}
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 Beginner ,
Dec 23, 2019 Dec 23, 2019
LATEST

It workes! Thank u verry 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