My JavaScript run twice instead of once
- October 1, 2019
- 3 Antworten
- 1155 Ansichten
I have a problem that drives me crazy.
In my PDF I use a function that fills the right drop-down menu and depends on the choice made in the left drop-down menu.
This function works well except that:
- When I use my function in "validation script" it acts with a delay time, it is the previous choice that is displayed in the right drop-down list. )See attachment).
- When I use my function in "custom format script" it runs twice. ( See attachment.)
• Once when you click on the list, as if there was a "mouse down" action, which immediately resets the right drop-down list.
• And a second time, as expected, when you validate a choice.
What do I need to change to be able to use my function as a "validation script" that don't acts with a delay time, or as a "custom format script" that only runs once after the user choice?
Thank you
My function:
function gereSousList() {
if (event.target.currentValueIndices != 0) {
// console.clear();
// récupération du suffixe du champ cliqué
var aTexte = event.target.name.split(".");
var nSuffix = aTexte.pop();
// console.println("nSuffix : "+nSuffix);
// récupération du numéro de l'item sélectionné
var cPos = event.target.currentValueIndices;
// console.println("cPos : "+cPos);
if (this.dataObjects[cPos] != undefined) {
// importation des données en fonction du numéro de l'item (fichier en PJ)
var p2 = this.getDataObject(this.dataObjects[cPos].name);
if (this.dataObjects != null) {
var fi2 = this.getDataObjectContents(p2.name);
var fit2 = util.stringFromStream(fi2);
// console.println("\n\nNom du fichier source : "+this.dataObjects[cPos].name);
// séparation des rangées
var datarr2 = fit2.split("\n");
// console.println("datarr2 : "+datarr2);
// remplissage de la liste déroulante
this.getField("SitProf.liste2." + nSuffix).clearItems();
this.getField("SitProf.liste2." + nSuffix).setItems(datarr2);
}
}
}
}

