Skip to main content
Known Participant
October 15, 2016
Question

PDF and JavaScript IF OR

  • October 15, 2016
  • 8 replies
  • 858 views

Hi, I'm doing conditions between two fields. after adding the last "else if" I can no longer do it makes me an error "SyntaxError: unterminated string literal".

if I stop me "status ==" OG - Worker "and I finish to calculate the value he accepts, but if one puts OR or an additional IF he made the mistake.

is what I am limited? anyone know the problem there? thank you

var societe = this.getField("societe").value;

var point = this.getField("NombreDePoints").value;

var statut = this.getField("statutSalarie").value

if((societe == "societe1" || societe == "societe2" ) && (statut == "OG - Ouvrier" || statut == "EH - Employés" || statut == "AE - Agent de maitrise GF" || statut == "AF - Agents de maitrise" || statut == "AD - Agent maitr art 36" || statut == "AC – Agent maitr art 4bis" || statut == "MD - Détaché" || statut == "TC - Technicien" || statut == "CB - Cadre intégré"))event.value = point * 12.0117;

else if((societe == "societe3" || societe == "societe4" || societe == "societe5" ||  societe == "societe6" || societe == "societe7" ) && (statut == "OG - Ouvrier" || statut == "EH - Employés" || statut == "AE - Agent de maitrise GF" || statut == "AF - Agents de maitrise" || statut == "AD - Agent maitr art 36" || statut == "AC – Agent maitr art 4bis" || statut == "MD - Détaché" || statut == "TC - Technicien" || statut == "CB - Cadre intégré"))event.value = point * 12.0845;

else if((societe == "societe8" || societe == "societe9" ) && (statut == "OG - Ouvrier" || statut == "EH - Employés" || statut == "AE - Agent de maitrise GF" || statut == "AF - Agents de maitrise" || statut == "AD - Agent maitr art 36" || statut == "AC – Agent maitr art 4bis" || statut == "MD - Détaché" || statut == "TC - Technicien" || statut == "CB - Cadre intégré"))event.value = point * 4.8688;

else if(societe == "societe10" && (statut == "OG - Ouvrier" || statut == "EH - Employés" || statut == "AE - Agent de maitrise GF" || statut == "AF - Agents de maitrise" || statut == "AD - Agent maitr art 36" || statut == "AC – Agent maitr art 4bis" || statut == "MD - Détaché" || statut == "TC - Technicien" || statut == "CB - Cadre intégré"))event.value = point * 11.9519;

else if(societe == "societe11" && (statut == "OG - Ouvrier" || statut == "EH - Employés"

This topic has been closed for replies.

8 replies

JR Boulay
Community Expert
Community Expert
October 15, 2016

Il faudrait savoir dans quel champ est placé le script et sur quel déclencheur.

Voir : http://abracadabrapdf.net/ressources-et-tutos/js-et-formulaires-ressources/lordre-dexecution-des-evenements-dans-les-cha…

Est-ce qu'on peut voir tout ou partie de ce formulaire ?

Acrobate du PDF, InDesigner et Photoshopographe
Known Participant
October 15, 2016

en fait toutes les solutions ne fonctionnent pas, du coup j’ai téléchargé une version d’essai de DC et pour le moment j’ai l’impression que ça fonctionne mieux.

je vais allé jusqu’au bout pour voir.

Je reviens vers toi pour te donner des infos

Le 15 oct. 2016 à 17:18, JR_Boulay <forums_noreply@adobe.com> a écrit :

PDF and JavaScript IF OR

created by JR_Boulay <https://forums.adobe.com/people/JR_Boulay> in PDF Forms - View the full discussion <https://forums.adobe.com/message/9069622#9069622>

Il faudrait savoir dans quel champ est placé le script et sur quel déclencheur.

Voir : http://abracadabrapdf.net/ressources-et-tutos/js-et-formulaires-ressources/lordre-dexecuti on-des-evenements-dans-les-cha… <http://abracadabrapdf.net/ressources-et-tutos/js-et-formulaires-ressources/lordre-dexecution-des-evenements-dans-les-champs-de-formulaire-pdf/>

Est-ce qu'on peut voir tout ou partie de ce formulaire ?

If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/9069622#9069622 and clicking ‘Correct’ below the answer

Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:

Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/9069622#9069622

To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"

Start a new discussion in PDF Forms by email <mailto:discussions-community-acrobat-forms@adobe-v8.hosted.jivesoftware.com> or at Adobe Community <https://forums.adobe.com/choose-container.jspa?contentType=1&containerType=14&container=4698>

For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624 <https://forums.adobe.com/thread/1516624>.

This email was sent by Adobe Community because you are a registered user.

You may unsubscribe <https://forums.adobe.com/unsubscribe.jspa?email=swoon.international%40gmail.com&token=8bb430fc54041e11fbb3d10a43a1d74f9ee91ac4f6dc00f7ded467f31c162d39> instantly from Adobe Community, or adjust email frequency in your email preferences <https://forums.adobe.com/user-preferences!input.jspa>

JR Boulay
Community Expert
Community Expert
October 15, 2016

Dans ce cas le plus sur est d'encoder toutes les chaines de caractères en Unicode, ça évite ce genre de problème.

Voir :

- http://abracadabrapdf.net/utilitaires/utilitaires-pdf/abra-txt2unicode-texte-vers-unicode/

- http://abracadabrapdf.net/ressources-et-tutos/js-et-formulaires-ressources/pdf-javascript-et-unicode/

.

Acrobate du PDF, InDesigner et Photoshopographe
Known Participant
October 15, 2016

Merci je vais regarder, car j’y connais rien

Le 15 oct. 2016 à 15:20, JR_Boulay <forums_noreply@adobe.com> a écrit :

PDF and JavaScript IF OR

created by JR_Boulay <https://forums.adobe.com/people/JR_Boulay> in PDF Forms - View the full discussion <https://forums.adobe.com/message/9069509#9069509>

Dans ce cas le plus sur est d'encoder toutes les chaines de caractères en Unicode, ça évite ce genre de problème : http://abracadabrapdf.net/utilitaires/utilitaires-pdf/abra-txt2unicode-texte-vers-unicode/ <http://abracadabrapdf.net/utilitaires/utilitaires-pdf/abra-txt2unicode-texte-vers-unicode/>

Oui, français de France.

If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/9069509#9069509 and clicking ‘Correct’ below the answer

Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:

Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/9069509#9069509

To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"

Start a new discussion in PDF Forms by email <mailto:discussions-community-acrobat-forms@adobe-v8.hosted.jivesoftware.com> or at Adobe Community <https://forums.adobe.com/choose-container.jspa?contentType=1&containerType=14&container=4698>

For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624 <https://forums.adobe.com/thread/1516624>.

This email was sent by Adobe Community because you are a registered user.

You may unsubscribe <https://forums.adobe.com/unsubscribe.jspa?email=swoon.international%40gmail.com&token=8bb430fc54041e11fbb3d10a43a1d74f9ee91ac4f6dc00f7ded467f31c162d39> instantly from Adobe Community, or adjust email frequency in your email preferences <https://forums.adobe.com/user-preferences!input.jspa>

JR Boulay
Community Expert
Community Expert
October 15, 2016

Bonjour.

On dirait que le problème vient de la syntaxe qui n'est pas correcte : il manque les accolades après les conditions et sur la dernière ligne il manque 2 parenthèses, les accolades et l'instruction à exécuter.

Essaye ça :

var societe = this.getField("societe").value;

//

var point = this.getField("NombreDePoints").value;

//

var statut = this.getField("statutSalarie").value

//

if((societe == "societe1" || societe == "societe2" ) && (statut == "OG - Ouvrier" || statut == "EH - Employés" || statut == "AE - Agent de maitrise GF" || statut == "AF - Agents de maitrise" || statut == "AD - Agent maitr art 36" || statut == "AC – Agent maitr art 4bis" || statut == "MD - Détaché" || statut == "TC - Technicien" || statut == "CB - Cadre intégré"))

{event.value = point * 12.0117;}

//

else if((societe == "societe3" || societe == "societe4" || societe == "societe5" ||  societe == "societe6" || societe == "societe7" ) && (statut == "OG - Ouvrier" || statut == "EH - Employés" || statut == "AE - Agent de maitrise GF" || statut == "AF - Agents de maitrise" || statut == "AD - Agent maitr art 36" || statut == "AC – Agent maitr art 4bis" || statut == "MD - Détaché" || statut == "TC - Technicien" || statut == "CB - Cadre intégré"))

{event.value = point * 12.0845;}

//

else if((societe == "societe8" || societe == "societe9" ) && (statut == "OG - Ouvrier" || statut == "EH - Employés" || statut == "AE - Agent de maitrise GF" || statut == "AF - Agents de maitrise" || statut == "AD - Agent maitr art 36" || statut == "AC – Agent maitr art 4bis" || statut == "MD - Détaché" || statut == "TC - Technicien" || statut == "CB - Cadre intégré"))

{event.value = point * 4.8688;}

//

else if(societe == "societe10" && (statut == "OG - Ouvrier" || statut == "EH - Employés" || statut == "AE - Agent de maitrise GF" || statut == "AF - Agents de maitrise" || statut == "AD - Agent maitr art 36" || statut == "AC – Agent maitr art 4bis" || statut == "MD - Détaché" || statut == "TC - Technicien" || statut == "CB - Cadre intégré"))

{event.value = point * 11.9519;}

//

else if(societe == "societe11" && (statut == "OG - Ouvrier" || statut == "EH - Employés"))

{// instructions à exécuter;}

Acrobate du PDF, InDesigner et Photoshopographe
Known Participant
October 15, 2016

Vous êtes Francais? merci beaucoup pour votre retour.

j'avais fait cette modification mais j'ai toujours une erreur. ci dessous le code que j'avais écrit et il me fait l'erreur suivante "SyntaxError: syntax error 17: à la ligne 18

j'ai l'impression que certaines infos société ne fonctionne pas correctement en remplaçant les mots société dans votre réponse ci dessus  Par exemple si je supprime le x dans "1007 - Sté Gestion Assainis BdxM" et que je valide il accepte le code. autre exemple si j'écris "1011 - OPELYS" il n'accepte pas le code par contre si j'écris 1011 seul il accepte le code.

et il m'est impossible d'ajouter de nouvelles lignes

Franchement je ne vois pas ce qui se passe

var societe = this.getField("societe").value;

var point = this.getField("NombreDePoints").value;

var statut = this.getField("statutSalarie").value

if((societe == "1010 - SUEZ" || societe == "0035 - SUEZ Groupe" ) && (statut == "OG - Ouvrier" || statut == "EH - Employés" || statut == "AE - Agent de maitrise GF" || statut == "AF - Agents de maitrise" || statut == "AD - Agent maitr art 36" || statut == "AC – Agent maitr art 4bis" || statut == "MD - Détaché" || statut == "TC - Technicien" || statut == "CB - Cadre intégré"))

{event.value = point * 12.0117;}

else if((societe == "0075 - SUEZ Eau France" || societe == "1011 - OPELYS" || societe == "1009 - ONDEO SYSTEMS" ||  societe == "1007 - Sté Gestion Assainis BdxM" || societe == "1005 - Sté Nancéienne des Eaux" ) && (statut == "OG - Ouvrier" || statut == "EH - Employés" || statut == "AE - Agent de maitrise GF" || statut == "AF - Agents de maitrise" || statut == "AD - Agent maitr art 36" || statut == "AC – Agent maitr art 4bis" || statut == "MD - Détaché" || statut == "TC - Technicien" || statut == "CB - Cadre intégré"))

{event.value = point * 12.0845;}

else if((societe == "1076 - EPURIA-Lyonnaise des eaux" || societe == "1077 - TERRE DE L'OUEST - LDE" ) && (statut == "OG - Ouvrier" || statut == "EH - Employés" || statut == "AE - Agent de maitrise GF" || statut == "AF - Agents de maitrise" || statut == "AD - Agent maitr art 36" || statut == "AC – Agent maitr art 4bis" || statut == "MD - Détaché" || statut == "TC - Technicien" || statut == "CB - Cadre intégré"))

{event.value = point * 4.8688;}

else if(societe == "1008 - Maison Pour Rebondir" && (statut == "OG - Ouvrier" || statut == "EH - Employés" || statut == "AE - Agent de maitrise GF" || statut == "AF - Agents de maitrise" || statut == "AD - Agent maitr art 36" || statut == "AC – Agent maitr art 4bis" || statut == "MD - Détaché" || statut == "TC - Technicien" || statut == "CB - Cadre intégré"))

{event.value = point * 11.9519;}

else if(societe == "0015 - Sté des Eaux de l'Essonne" && (statut == "OG - Ouvrier" || statut == "EH - Employés"))

{event.value = point * 6.4958;}

else

{event.value = "";}