Javascript help

Community Beginner ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

FIELD NAME: TOTAL, LINE2, LINE3, CHECKBOX1 YES, CHECKBOX1 NO.

please i need a script where if TOTAL is more than 600, CHECKBOX1 YES will be clicked and substract 600 from TOTAL

and enter the result in LINE2.

If no CHECKBOX1 NO will be clicked and enter 0 in LINE3.

Note: the check boxes are part of the same group

 

Thanks!!!!!

 

 

 

 

TOPICS
JavaScript

Views

3.5K

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
community guidelines
Enthusiast ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

Checkboxes are checked automaticaly depending of value in total?

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
community guidelines
Community Beginner ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

Yes

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
community guidelines
Community Beginner ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

FIELD NAME: TOTAL, LINE2, LINE3, CHECKBOX1 YES, CHECKBOX1 NO.

please i need a script where if TOTAL is more than 600, CHECKBOX1 YES will checked automaticaly and substract 600 from TOTAL

and enter the result in LINE2.

If no, CHECKBOX1 NO will checked automaticaly and enter 0 in LINE3.

Notes: the check boxes are part of the same group

 

Thanks!!!!!

 

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
community guidelines
Adobe Community Professional ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

You can use this script in TOTAL field:

if(event.value > 600){
this.getField("CHECKBOX1").value = "YES";
this.getField("LINE2").value = event.value-600;}
else if(event.value <= 600){
this.getField("CHECKBOX1").value = "NO";
this.getField("LINE3").value = 0;}

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
community guidelines
Community Beginner ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

I want to add the script in a hidden new field instead.

How can i do that 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
community guidelines
Adobe Community Professional ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

Just replace 'event.value' with:

this.getField("TOTAL").value

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
community guidelines
Community Beginner ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

Ok i will try my best thank you very much!!!

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
community guidelines
Community Beginner ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

It works!!!! But the issue now when TOTAL is blank or when resetting the form, the CHECKBOX1 NO is still being checked and LINE3 is still says 0

To eliminate that i add this script at the end:

else if(this.getField("TOTAL").value = "";){

this.getField("CHECKBOX1").value = "";

this.getField("LINE3").value = "";}

 

But I got error!!! What did i do wrong 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
community guidelines
Adobe Community Professional ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

Remove the semi-colon in the parentheses after if.

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
community guidelines
Community Beginner ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

if(this.getField("TOTAL").value > 600){
this.getField("CHECKBOX1").value = "YES";
this.getField("LINE2").value = event.value-600;}
else if(event.value <= 600){
this.getField("CHECKBOX1").value = "NO";
this.getField("LINE3").value = 0;}

else if(this.getField("TOTAL").value = ""{

this.getField("CHECKBOX1").value = "";

this.getField("LINE3").value = "";}

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
community guidelines
Community Beginner ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

Syntax Error: missing ) after condition 7: at line 8

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
community guidelines
Adobe Community Professional ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

if(this.getField("TOTAL").value > 600){
this.getField("CHECKBOX1").value = "YES";
this.getField("LINE2").value = event.value-600;}
else if(event.value <= 600){
this.getField("CHECKBOX1").value = "NO";
this.getField("LINE3").value = 0;}

else if(this.getField("TOTAL").value = ""){

this.getField("CHECKBOX1").value = "";

this.getField("LINE3").value = "";}

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
community guidelines
Community Beginner ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

Ok i got it thanks a lot!!!

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
community guidelines
Community Beginner ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

Thanks a lot!!!

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
community guidelines
Community Beginner ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

LATEST

Any recommended video or lessons so i could lean all those script please?

Thanks again!!!

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
community guidelines
Adobe Community Professional ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

How do you currently calculate the TOTAL field? Do you use a script?

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
community guidelines
Community Beginner ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

Yes

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
community guidelines