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

Javascript help

Community Beginner ,
May 02, 2021 May 02, 2021

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
1.5K
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
1 ACCEPTED SOLUTION
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.

View solution in original post

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

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

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

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

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

For less or equal use this:  <=

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

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