abracadabraPDF › Forums › PDF – Général › Script qui marche en partie › Répondre à : Script qui marche en partie

bonjour,
Pourquoi revérifier tous les champs à chaque fois ???
Tu peux utiliser cette fonction :
function laCouleur(nomChamp) {
if (!this.getField(nomChamp).isBoxChecked(0)) {
this.getField(nomChamp.toUpperCase()).textColor=color.black;
if (nomChamp.split(".")[0]=="a") this.getField(nomChamp.toUpperCase()).fillColor=color.red;
else this.getField(nomChamp.toUpperCase()).fillColor=color.blue;
} else {
this.getField(nomChamp.toUpperCase()).fillColor=color.transparent;
if (nomChamp.split(".")[0]=="a") this.getField(nomChamp.toUpperCase()).textColor=color.red;
else this.getField(nomChamp.toUpperCase()).textColor=color.blue;
}
}
Et l’appeler avec :
laCouleur(event.target.name);
Pour écrire cette ligne avec toutesles cases à cocher tu peux exécuter de la console :
for (var i=0; i<this.numFields; i++) {
var nomChamp=this.getNthFieldName(i);
var f=this.getField(this.getNthFieldName(i));
if (f.type=="checkbox" && (this.getNthFieldName(i).indexOf("a.")==0 || this.getNthFieldName(i).indexOf("b.")==0)) f.setAction("MouseUp","laCouleur(event.target.name);")
}
@+
😎