Skip to main content
Participating Frequently
December 23, 2019
Answered

AutoFill checkbox from a drop - down - list

  • December 23, 2019
  • 1 reply
  • 920 views

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);
}

 

 

This topic has been closed for replies.
Correct answer Bernd Alheit

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);
}

1 reply

Bernd Alheit
Community Expert
December 23, 2019

You must use false, not fals

F. Graf Author
Participating Frequently
December 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);
}

Bernd Alheit
Bernd AlheitCorrect answer
Community Expert
December 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);
}