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

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

3.5K

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

Try this:

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

Votes

Translate

Translate
Community Expert ,
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 : "";

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

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

Copy link to clipboard

Copied

You have script in validation or calculation?

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

Copy link to clipboard

Copied

Script is in Custom calculation

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

Try this:

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

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

Copy link to clipboard

Copied

Works perfecly thanks a lot!!!!

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

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

Copy link to clipboard

Copied

I meant to say leave the field blank

 

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

}

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

Copy link to clipboard

Copied

 Script has to be in box1

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

Copy link to clipboard

Copied

Why?

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

Copy link to clipboard

Copied

LATEST

Why??????

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