• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

4.4K

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?

Votes

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

Votes

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!!!!!

 

Votes

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 Expert ,
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;}

Votes

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?

Votes

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 Expert ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

Just replace 'event.value' with:

this.getField("TOTAL").value

Votes

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!!!

Votes

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?

Votes

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 Expert ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

Remove the semi-colon in the parentheses after if.

Votes

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 = "";}

Votes

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

Votes

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 Expert ,
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 = "";}

Votes

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!!!

Votes

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!!!

Votes

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!!!

Votes

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 Expert ,
May 08, 2021 May 08, 2021

Copy link to clipboard

Copied

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

Votes

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

Votes

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