Skip to main content
Participant
August 4, 2024
Question

amp formulaire pdf conditionnel

  • August 4, 2024
  • 1 reply
  • 419 views

Bonjour,

je n'arrive pas à écrire le bon scripte pour un calcul conditionnel dans le formulaire pdf acrobat:

Champ 1 (B2) = liste avec choix =1 ou choix =2

Champ 2 (C2) = chiffre à remplir par la personne

Champ 3 = résultat calculé

Dans excel cela donne:
=SI(B2=1;C2;SI(B2=2;C2*1,5))
Merci!

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 4, 2024

Try this code as the custom calculation script:

 

var B2 = this.getField("B2").valueAsString;
var C2 = Number(this.getField("C2").valueAsString);
if (B2=="1") event.value = 1;
else if (B2=="2") event.value = C2*1.5;
else event.value = "";
Participant
August 5, 2024

Hello and thank you, it's perfect like this and I understand 😉
There is just on the 3rd line, the modification *1

if (B2=="1") event.value = C2*1;

A beautiful day

 

try67
Community Expert
Community Expert
August 5, 2024

Ah sorry, I misread the syntax of the Excel formula.

Use this:

 

else if (B2=="2") event.value = C2;
else event.value = 5;

 

There's no need to multiply by one.