auto populate field from drop down list

New Here ,
Jan 08, 2020

Copy link to clipboard

Copied

Hello, I created a drop-down list and a text field, I automatically fill in according to the list but sometimes I need to modify the text in the text field, I can't;
for example the ZCQJ006 can be 70 and can be 80 and sometimes even 85, please help

drop-down = NGAPCCAM       text field1 = paiement   text field2 = Somme

javascript = 

var f = this.getField("NGAPCCAM");

var g = this.getField("paiement");

if ((f.valueAsString=="ZCQJ006") && (g.valueAsString == "CMU")) {this.getField("Somme").value = "70"; 

TOPICS
Acrobat SDK and JavaScript, Create PDFs, Edit and convert PDFs, How to, PDF forms

Views

142

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

auto populate field from drop down list

New Here ,
Jan 08, 2020

Copy link to clipboard

Copied

Hello, I created a drop-down list and a text field, I automatically fill in according to the list but sometimes I need to modify the text in the text field, I can't;
for example the ZCQJ006 can be 70 and can be 80 and sometimes even 85, please help

drop-down = NGAPCCAM       text field1 = paiement   text field2 = Somme

javascript = 

var f = this.getField("NGAPCCAM");

var g = this.getField("paiement");

if ((f.valueAsString=="ZCQJ006") && (g.valueAsString == "CMU")) {this.getField("Somme").value = "70"; 

TOPICS
Acrobat SDK and JavaScript, Create PDFs, Edit and convert PDFs, How to, PDF forms

Views

143

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 08, 2020 0
Adobe Community Professional ,
Jan 08, 2020

Copy link to clipboard

Copied

Is this a calculation script? And on which field is it located?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2020 0
New Here ,
Jan 08, 2020

Copy link to clipboard

Copied

yes calculation script

drop down liste = NGAPCCAM

field 1 = paiement 

field 2 = Somme

if i choose ZCQJ006 in the drop down list 

and I chosse CMU in the field 1

i get the Somme auto filed in the field 2  by the number 70 

but I need sometimes another number like 80 or 85 in the Somme

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2020 0
Most Valuable Participant ,
Jan 08, 2020

Copy link to clipboard

Copied

You can duplicate the last line of code with the new values you want to test.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2020 0
New Here ,
Jan 08, 2020

Copy link to clipboard

Copied

it did't work

it takes the last number only

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2020 0
Most Valuable Participant ,
Jan 08, 2020

Copy link to clipboard

Copied

Post your full code, please.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2020 0
New Here ,
Jan 08, 2020

Copy link to clipboard

Copied

var f = this.getField("NGAPCCAM");

var g = this.getField("Moyen paiement");

if ((f.valueAsString=="ZCQJ006") && (g.valueAsString == "Carte Bancaire", "Espèce", "Chèque")) {this.getField("Somme").value = "70 €";}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2020 0
Most Valuable Participant ,
Jan 08, 2020

Copy link to clipboard

Copied

That's not what I said you should do. Anyway, try this:

 

if ((f.valueAsString=="ZCQJ006") && (g.valueAsString == "Carte Bancaire" || g.valueAsString == "Espèce" || g.valueAsString == "Chèque")) {this.getField("Somme").value = "70 €";}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2020 0
New Here ,
Jan 08, 2020

Copy link to clipboard

Copied

thanks for correcting my formula, but i still can't change the sum 70,
even when i duplicate the line 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2020 0
Most Valuable Participant ,
Jan 08, 2020

Copy link to clipboard

Copied

Again, post your full code.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2020 0
New Here ,
Jan 08, 2020

Copy link to clipboard

Copied

var f = this.getField("NGAPCCAM1");

var g = this.getField("Moyen paiement 1");

if ((f.valueAsString=="CS MCS MPC") && (g.valueAsString == "CMU"))

{this.getField("Somme1").value = "30 €";}

else if ((f.valueAsString=="CS MCS MPC JKHD001") && (g.valueAsString == "CMU"))

{this.getField("Somme1").value = "42,46 €";}

else if ((f.valueAsString=="JQQM002") && (g.valueAsString == "Carte Bancaire", "Espèce", "Chèque"))

{this.getField("Somme1").value = "69,93 €";}

else if ((f.valueAsString=="ZCQJ006") && (g.valueAsString == "Carte Bancaire" || g.valueAsString == "Espèce" || g.valueAsString == "Chèque"))

{this.getField("Somme1").value = "70 €";}

else if ((f.valueAsString=="ZCQJ002") && (g.valueAsString == "Carte Bancaire", "Espèce", "Chèque"))

{this.getField("Somme1").value = "85 €";}

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2020 0
Most Valuable Participant ,
Jan 08, 2020

Copy link to clipboard

Copied

Stop using commas. Use the OR operator (||), like in my example above.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2020 0
New Here ,
Jan 10, 2020

Copy link to clipboard

Copied

I changed everything to OR operator (||), 

I duplicated the line it dosn't work

i choose 70, and as soons as I work on the nexte field, it comes back 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 10, 2020 0
Most Valuable Participant ,
Jan 10, 2020

Copy link to clipboard

Copied

For the last time, post your full code.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 10, 2020 0
New Here ,
Jan 10, 2020

Copy link to clipboard

Copied

I SENT YOU THE PDF BY EMAIL

I DON4T KNOW HOW TO ATTACHE IT HERE

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 10, 2020 0