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

Javascript help

Community Beginner ,
May 07, 2021 May 07, 2021

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
5.1K
Translate
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

Checkboxes are checked automaticaly depending of value in total?

Translate
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

Yes

Translate
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

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

 

Translate
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

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

Translate
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

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

How can i do that please?

Translate
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

Just replace 'event.value' with:

this.getField("TOTAL").value

Translate
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

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

Translate
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

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?

Translate
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
Remove the semi-colon in the parentheses after if.
Translate
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

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

Translate
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

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

Translate
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

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

Translate
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

Ok i got it thanks a lot!!!

Translate
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

Thanks a lot!!!

Translate
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
LATEST

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

Thanks again!!!

Translate
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

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

Translate
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

Yes

Translate
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