Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


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

322

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

correct answers 1 Correct answer

Adobe Community Professional , 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.

Likes

Translate

Translate
Adobe Community Professional ,
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.

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

Copy link to clipboard

Copied

I was putting the wrong script now it works perfectly 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
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!!!!

 

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

Copy link to clipboard

Copied

For less or equal use this:  <=

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

Copy link to clipboard

Copied

LATEST

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