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

Javasript help

Community Beginner ,
May 04, 2021 May 04, 2021

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

Try this:

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

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

As validation script of box2 use this:

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

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

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

You have script in validation or calculation?

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

Script is in Custom calculation

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

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

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

Try this:

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

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

Works perfecly thanks a lot!!!!

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

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?

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

I meant to say leave the field blank

 

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

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

}

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

 Script has to be in box1

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

Why?

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

Why??????

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