abracadabraPDF › Forums › PDF – Général › Problème de lancement d’un script › Répondre à : Problème de lancement d’un script

Merci pour les réponses.
@BB : J’ai modifié mon script Default ainsi
function Default() {
for (var i=0; i<this.numFields; i++) {
var nomChamp=this.getNthFieldName(i);
//console.println(i+" - nomChamp : "+nomChamp+" - "+(this.getField(nomChamp).page+1)+" - "+this.getField(nomChamp).type);
if (nomChamp.indexOf("R.")==0) {
if (this.getField(nomChamp).type=="text") this.getField(nomChamp).defaultValue=this.getField(nomChamp).value;
if ((this.getField(nomChamp).type=="checkbox" || this.getField(nomChamp).type=="radiobutton")) this.getField(nomChamp).defaultValue=this.getField(nomChamp).value;
}
if (nomChamp.indexOf("Q.")==0) {
if (this.getField(nomChamp).type=="text") {this.getField(nomChamp).value="";}
if ((this.getField(nomChamp).type=="checkbox" || this.getField(nomChamp).type=="radiobutton")) this.getField(nomChamp).value="Off";
if (this.getField(nomChamp).type=="combobox") {this.getField(nomChamp).value=this.getField(nomChamp).getItemAt(0,false);}
}
if (nomChamp.indexOf("Titre.")==0) {this.getField(nomChamp).defaultValue=this.getField(nomChamp).value;}
if (nomChamp.indexOf("TQ.")==0) {this.getField(nomChamp).defaultValue=this.getField(nomChamp).value;}
if (nomChamp.indexOf("Question.")==0) {this.getField(nomChamp).defaultValue=this.getField(nomChamp).value;}
if (nomChamp.indexOf("Aide." && this.getField(nomChamp).type=="text")==0) {this.getField(nomChamp).defaultValue=this.getField(nomChamp).value;}
if (nomChamp.indexOf("TL.")==0 && this.getField(nomChamp).type=="text") {this.getField(nomChamp).defaultValue="";}
if (nomChamp.indexOf("Menu.")==0) {
this.getField("Menu.3").fillColor=color.green;
this.getField("Menu.4").fillColor=color.green;
if (this.getField(nomChamp).type=="text") this.getField(nomChamp).defaultValue=this.getField(nomChamp).value;
if ((this.getField(nomChamp).type=="checkbox" || this.getField(nomChamp).type=="radiobutton")) this.getField(nomChamp).value="Off";
}
}}
Dans la 1ère condition (ligne 7 à 10) et pour la dernière (ligne 25 à 30) je ne sais pas comment écrire : si le champ est de type combobox alors la valeur par defaut sera la valeur sélectionnée dans la combobox.
Pour le reste, je crois avoir compris ce qui pose problème, je pense que ça fonctionne. Le fichier est en pj
@ Merlin :
J’ai renomé la fonction random → hasard
J’ai crée un formulaire avec uniquement ces 2 scripts pour que ce ne soit pas pollué par d’autres scripts de mon pdf qui en contient énormément et j’ai toujours le même problème :
cela fonctionne quand j’appele la fonction via le script du bouton démarrer
mais ça ne fonctionne plus quand j’apelle la fonction par la commande aleatoir(); (bouton Aleatoir)
Fichier (aleatoir) en piece jointe