• 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 02, 2021 May 02, 2021

Copy link to clipboard

Copied

Field name: box1, box2, box3, box4, box5, box6, box7, box8, box9, box10, box11

Total1 = box1+box2+box3+box4

Total2 = box5+box6+box7+box8

Total3 = box9+box10+box11

Box3 = the amount from Total3

Total4 = Total1+Total2

Please I need the custom script for:

Total1, Total4, box3  

And to leave blank when equal 0

Thanks!!!!!

 

 

 

 

 

 

 

TOPICS
JavaScript

Views

1.1K

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

correct answers 1 Correct answer

Community Expert , May 03, 2021 May 03, 2021

For Total1:

var x = Number(this.getField("box1").value)+Number(this.getField("box2").value)+Number(this.getField("box3").value)+Number(this.getField("box4").value);
if(x == 0)
event.value = "";
else event.value = x;

You can easily adapt code for other fields.

Votes

Translate

Translate
Community Expert ,
May 03, 2021 May 03, 2021

Copy link to clipboard

Copied

For Total1:

var x = Number(this.getField("box1").value)+Number(this.getField("box2").value)+Number(this.getField("box3").value)+Number(this.getField("box4").value);
if(x == 0)
event.value = "";
else event.value = x;

You can easily adapt code for other fields.

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 03, 2021 May 03, 2021

Copy link to clipboard

Copied

I was putting the wrong script now it works perfectly 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 Beginner ,
May 03, 2021 May 03, 2021

Copy link to clipboard

Copied

How do i write the condition for the same script above:  If  x  is less or equal to zero

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 03, 2021 May 03, 2021

Copy link to clipboard

Copied

For less or equal use this:  <=

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 04, 2021 May 04, 2021

Copy link to clipboard

Copied

LATEST

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