abracadabraPDF › Forums › PDF – Général › Liste MEre Fille – que faire du bout de code ?
- Ce sujet est vide.
-
CréateurSujet
-
1 juillet 2021 à 16:28 #46630
Justy
Participantbonjour,sur ce sujet
j’ai trouvé ce bout de code/exemple qui correspond à ce que je souhaite ( Liste Mere Fille ) – je n’ai pas de 3eme niveau
comment puis je le déporter sur mon tableau partiel ( en PJ )il faudras dupliquer celui ci sur les 12 lignes de mon tableaumerci
-
CréateurSujet
-
AuteurRéponses
-
6 juillet 2021 à 08:54 #69417
Merlin
Maître des clésBonjour
L’exemple ( http://practicalpdf.com/acrobat-javascript-examples/dependentLists.pdf ) fourni sur la page que tu cites me parait simple à adapter, il te suffit de copier-coller les deux listes déroulantes et d’adapter le script, qui se trouve dans le champ “masterDropdown”.
Pour la duplication c’est à peine plus compliqué, il faut dans le script adapter le nom du champ cible (dependentDropdown.1, dependentDropdown.2, dependentDropdown.3, etc).
11 août 2021 à 17:47 #69418Justy
Participantmerci pour ta réponse
pour l’histoire du code à copier/coller/adapter, OKmais ou dois je rentrer les listes ?quelque part ou les choix sont contenu dans le bout de code11 août 2021 à 20:32 #69419bebarth
Maître des clésbonjour,
Juste quelques lignes à modifier :Code:*/
var dependentListBoxFieldName = “ListeFille”;
var dependentListValues =
{
“C”: [
[“C1”, “export C1”],
[“C2”, “export C2”],
[“C3”, “export C3”]
],
“B”: [
[“B1”, “export B1”],
[“B2”, “export B2”],
[“B3”, “export B3”]
],
“M”: [
[“M1”, “export M1”],
[“M2”, “export M2”],
[“M3”, “export M3”]
],
“L”: [
[“L1”, “export L1”],
[“L2”, “export L2”],
[“L3”, “export L3”]
]
};
/*@+
:bonjour:13 août 2021 à 17:52 #69420Justy
Participantje te remercie
j’ai remarquer à posteriori le fichier jointj’aurais une petite faveur
dans le menu mère,
peux tu me rajouter C – B – M1 – M2 – L ( soit un 4éme choix possible au lieu de 3 )pour la liste fille,tu as mis 3 choix possible { X1 – X2 et X3},peux tu mettre 9 choix possible pour chaque ( mon choix max étant de 9 pour M1 )
13 août 2021 à 20:26 #69421bebarth
Maître des clésbonjour,
Désolé je suis en congés juste avec mon téléphone jusqu’au 1 septembre…
Mais avec le code fourni je pense que ce n’est pas très difficile à comprendre !
@+
:bonjour:14 août 2021 à 07:50 #69422Justy
Participantj’ai ajouter les choix dans le code de la Liste Mere
mais celui ci refuse de la valider, il bloque à la ligne “
[“Bu”, “export Lo1”],j’ai du faire une erreur dans le format à fournir
Code:/*
LICENSE:
acrojs_dependentList.js by Joel Geraci is licensed under a Creative Commons Attribution 4.0 International License.
https://creativecommons.org/licenses/by/4.0/You are free to:
Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material for any purpose, even commercially.Setup:
For list boxes: Add this script to the “selection change” script of the master list box.
For combo boxes: Add this script to the “custom format” script of the dropdown box.IMPORTANT!
Edit the following line to identify the field name of the dependent list box then edit the properties of the dependentListValues JSON object. Property names should correspond to the export values of the list items.
*/
var dependentListBoxFieldName = “ListeFille”;
var dependentListValues =
{
“Clés”: [
[“PG”, “export C1”],
[“PP”, “export C2”],
[“CBI”, “export C3”]
[“PAC”, “export C4”]
[“A(à préciser)”, “export C5”]
],
“Badges”: [
[“CA”, “export B1”],
[“Ca”, “export B2”],
[“Co”, “export B3”]
[“A(àpréciser)”, “export B4”]
],
“Matériels”: [
[“Tel”, “export Ma1”],
[“Ord”, “export Ma2”],
[“Ta”, “export Ma3”]
[“Im”, “export Ma4”]
[“EV”, “export Ma5”]
[“VP”, “export Ma6”]
[“RS”, “export Ma7”]
[“C(à préciser)”, “export Ma8”]
[“Autre (àpréciser)”, “export Ma9”]
],
“Mobiliers”: [
[“Ves”, “export Mo1”],
[“Bu/Ta”, “export Mo2”],
[“AH”, “export Mo3”]
[“AB”, “export Mo4”]
[“A(à préciser)”, “export Mo5”]
[“A( à préciser)”, “export Mo6”]
]
“Locaux”: [
[“Bu”, “export Lo1”],
[“Ves”, “export Lo2”],
[“Re/St”, “export Lo3”]
[“Ac/De”, “export Lo4”]
[“A( à préciser)”, “export Lo5”]
]
};
/*
You probably don’t need to change anything from here down
*/
if ((event.target.type == “combobox” && event.name == “Format”) || (event.target.type == “listbox” && event.name == “Keystroke”)) {
if (event.target.type == “combobox”) {
if (dependentListValues.hasOwnProperty(event.target.value)) {
this.getField(dependentListBoxFieldName).setItems(dependentListValues[event.target.value]);
}
else {
this.getField(dependentListBoxFieldName).clearItems();
}
}
if (event.target.type == “listbox” && dependentListValues.hasOwnProperty(event.changeEx)) {
this.getField(dependentListBoxFieldName).setItems(dependentListValues[event.changeEx]);
}
}
else {
app.alert(“This script was not intended for this field type or event.”);
}14 août 2021 à 08:03 #69423bebarth
Maître des clésIl manque une virgule après chaque élément (normalement sauf le dernier mais si ce n’est pas grave si tu en mets une).
[“Ta”, “export Ma3”],
@+
:bonjour:14 août 2021 à 08:34 #69424Justy
Participantj’ai ajouter les virgulesmais ils continue de bloquer sur la même ligne
Code:[“Bu”, “export Lo1”],Code:/*
LICENSE:
acrojs_dependentList.js by Joel Geraci is licensed under a Creative Commons Attribution 4.0 International License.
https://creativecommons.org/licenses/by/4.0/You are free to:
Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material for any purpose, even commercially.Setup:
For list boxes: Add this script to the “selection change” script of the master list box.
For combo boxes: Add this script to the “custom format” script of the dropdown box.IMPORTANT!
Edit the following line to identify the field name of the dependent list box then edit the properties of the dependentListValues JSON object. Property names should correspond to the export values of the list items.
*/
var dependentListBoxFieldName = “ListeFille”;
var dependentListValues =
{
“Clés”: [
[“PG”, “export C1”],
[“PP”, “export C2”],
[“CBI”, “export C3”],
[“PAC”, “export C4”],
[“A(à préciser)”, “export C5”],
],
“Badges”: [
[“CA”, “export B1”],
[“Ca”, “export B2”],
[“Co”, “export B3”],
[“A(àpréciser)”, “export B4”],
],
“Matériels”: [
[“Tel”, “export Ma1”],
[“Ord”, “export Ma2”],
[“Ta”, “export Ma3”],
[“Im”, “export Ma4”],
[“EV”, “export Ma5”],
[“VP”, “export Ma6”],
[“RS”, “export Ma7”],
[“C(à préciser)”, “export Ma8”],
[“Autre (àpréciser)”, “export Ma9”],
],
“Mobiliers”: [
[“Ves”, “export Mo1”],
[“Bu/Ta”, “export Mo2”],
[“AH”, “export Mo3”],
[“AB”, “export Mo4”],
[“A(à préciser)”, “export Mo5”],
[“A( à préciser)”, “export Mo6”],
]
“Locaux”: [
[“Bu”, “export Lo1”],
[“Ves”, “export Lo2”],
[“Re/St”, “export Lo3”],
[“Ac/De”, “export Lo4”],
[“A( à préciser)”, “export Lo5”],
]
};
/*
You probably don’t need to change anything from here down
*/
if ((event.target.type == “combobox” && event.name == “Format”) || (event.target.type == “listbox” && event.name == “Keystroke”)) {
if (event.target.type == “combobox”) {
if (dependentListValues.hasOwnProperty(event.target.value)) {
this.getField(dependentListBoxFieldName).setItems(dependentListValues[event.target.value]);
}
else {
this.getField(dependentListBoxFieldName).clearItems();
}
}
if (event.target.type == “listbox” && dependentListValues.hasOwnProperty(event.changeEx)) {
this.getField(dependentListBoxFieldName).setItems(dependentListValues[event.changeEx]);
}
}
else {
app.alert(“This script was not intended for this field type or event.”);
}14 août 2021 à 08:55 #69425Merlin
Maître des clésUne virgule vous manque et rien ne va plus :geek:
var dependentListBoxFieldName = “ListeFille”;
var dependentListValues =
{
“Clés”: [
[“PG”, “export C1”],
[“PP”, “export C2”],
[“CBI”, “export C3”],
[“PAC”, “export C4”],
[“A(à préciser)”, “export C5”],
],
“Badges”: [
[“CA”, “export B1”],
[“Ca”, “export B2”],
[“Co”, “export B3”],
[“A(àpréciser)”, “export B4”],
],
“Matériels”: [
[“Tel”, “export Ma1”],
[“Ord”, “export Ma2”],
[“Ta”, “export Ma3”],
[“Im”, “export Ma4”],
[“EV”, “export Ma5”],
[“VP”, “export Ma6”],
[“RS”, “export Ma7”],
[“C(à préciser)”, “export Ma8”],
[“Autre (àpréciser)”, “export Ma9”],
],
“Mobiliers”: [
[“Ves”, “export Mo1”],
[“Bu/Ta”, “export Mo2”],
[“AH”, “export Mo3”],
[“AB”, “export Mo4”],
[“A(à préciser)”, “export Mo5”],
[“A( à préciser)”, “export Mo6”],
], // <-- la virgule manquante est ici
“Locaux”: [
[“Bu”, “export Lo1”],
[“Ves”, “export Lo2”],
[“Re/St”, “export Lo3”],
[“Ac/De”, “export Lo4”],
[“A( à préciser)”, “export Lo5”],
]
};
/*
You probably don’t need to change anything from here down
*/
if ((event.target.type == “combobox” && event.name == “Format”) || (event.target.type == “listbox” && event.name == “Keystroke”)) {
if (event.target.type == “combobox”) {
if (dependentListValues.hasOwnProperty(event.target.value)) {
this.getField(dependentListBoxFieldName).setItems(dependentListValues[event.target.value]);
}
else {
this.getField(dependentListBoxFieldName).clearItems();
}
}
if (event.target.type == “listbox” && dependentListValues.hasOwnProperty(event.changeEx)) {
this.getField(dependentListBoxFieldName).setItems(dependentListValues[event.changeEx]);
}
}
else {
app.alert(“This script was not intended for this field type or event.”);
} -
AuteurRéponses
- Vous devez être connecté pour répondre à ce sujet.