abracadabraPDF › Forums › PDF – Général › Propriété d’un champ › Répondre à : Propriété d’un champ

Je ne sais pas si ça vient du collage dans l’éditeur de texte du forum mais il y a un problème avec les guillemets, JavaScript ne comprend que les guillemets droits.
Pour éviter toute erreur de format avec l’éditeur de texte il faut sélectionner le script et sélectionner “Code” dans le menu “Format”.
Par ailleurs tu devrais utiliser “else if” après le premier “if”, ça évite au script de tester inutilement toutes les conditions et donc ça devrait accélérer son exécution.
function CoulQ() {
var Coul=this.getField("Menu.3").value;
if (Coul=="Aucune") {
for (var i=0; i<this.numFields; i++) {
if (this.getNthFieldName(i).indexOf("question.")==0) {this.getField("question."+i).fillColor = color.transparent;}
}
}
else if (Coul=="Jaune") {
for (var i=0; i<this.numFields; i++) {
if (this.getNthFieldName(i).indexOf("question.")==0) {this.getField("question."+i).fillColor = color.yellow;}
}
}
else if (Coul=="Vert") {
for (var i=0; i<this.numFields; i++) {
if (this.getNthFieldName(i).indexOf("question.")==0) {this.getField("question."+i).fillColor = color.green;}
}
}
else if (Coul=="Bleu") {
for (var i=0; i<this.numFields; i++) {
if (this.getNthFieldName(i).indexOf("question.")==0) {this.getField("question."+i).fillColor = color.blue;}
}
}
else if (Coul=="Rouge") {
for (var i=0; i<this.numFields; i++) {
if (this.getNthFieldName(i).indexOf("question.")==0) {this.getField("question."+i).fillColor = color.red;}
}
}
}