Javasript help

Community Beginner ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

box1 = 500

box2

box3 = box1- box2

I want the field value from box1 to display and active only when there is value in box2.

The script please For box1?

 

TOPICS
JavaScript

Views

2.5K

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 06, 2021 May 06, 2021
Try this: event.value = this.getField("box2").value != "" ? 500 : "";

Likes

Translate

Translate
Adobe Community Professional ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

As validation script of box2 use this:

this.getField("box1").value = event.value != "" ? 500 : "";

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

Copy link to clipboard

Copied

I'm sorry since box2 already have another script when i try to add this script to the bottom of it, it is not working. The new script that i need has to be in box1

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
Enthusiast ,
May 06, 2021 May 06, 2021

Copy link to clipboard

Copied

You have script in validation or calculation?

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

Copy link to clipboard

Copied

Script is in Custom calculation

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
Enthusiast ,
May 06, 2021 May 06, 2021

Copy link to clipboard

Copied

As Nesa said use it in validation, read her post above please.

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

Copy link to clipboard

Copied

Try this:

event.value = this.getField("box2").value != "" ? 500 : "";

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

Copy link to clipboard

Copied

Works perfecly thanks a lot!!!!

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

Copy link to clipboard

Copied

Hi,

 

Can I clarify what you want to happen.

Starting point of document

[box1 hidden]

box2 has no value

box3 = ????

 

Then the user enters a value in box2

box1 = 500

box2 = 10

box3 = 490

 

So the key parts are what does box3 equal when box1 is hidden, as hidden just means the user can't see it?

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

Copy link to clipboard

Copied

I meant to say leave the field blank

 

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

Copy link to clipboard

Copied

Hi,

 

Then you probably want to place 2 small scripts, one to deal with the show hide and one to deal with the calculation.

 

In the validation of box2, you can place something like

// this shows and hides box1 based on box3 having a value.

if ( event.value !== "" ) {

  this.getField("box1").display = display.visible;

} else {

 this.getField("box1").display = display.hidden;

}

note: the above does not check it is a sensible value, just a value.

 

Then in the validation of box3 you can put something like:

var box2Value = this.getField("box2").value;

if (box2Value !== "" ){

event.value = 500 - box2Value;

} else {

event.value = "";

}

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

Copy link to clipboard

Copied

 Script has to be in box1

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
Enthusiast ,
May 06, 2021 May 06, 2021

Copy link to clipboard

Copied

Why?

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

Copy link to clipboard

Copied

LATEST

Why??????

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