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

Hide or calculate field based on another field

Explorer ,
Aug 08, 2024 Aug 08, 2024

Copy link to clipboard

Copied

I have below script. But I cannot seem to get it to work.

var v1 = Number(this.getField("Text2").value);
if (v1=="") eventvalue = "";
else event.value = v1-0.75

 

I had below before, which worked. But then I also need field Tex5 to be hidden when Text2 is empty

var v1 = Number(this.getField("Text2").value)
event.value = v1-0.75

TOPICS
JavaScript , PDF

Views

178

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 2 Correct answers

Community Expert , Aug 08, 2024 Aug 08, 2024

Try this:

var v1 = Number(this.getField("Text2").value);
if (v1==0) event.value = "";
else event.value = v1-0.75

Votes

Translate

Translate
Community Expert , Aug 09, 2024 Aug 09, 2024

You can change it at:

Bild1.jpg

Votes

Translate

Translate
Community Expert ,
Aug 08, 2024 Aug 08, 2024

Copy link to clipboard

Copied

Try this:

var v1 = Number(this.getField("Text2").value);
if (v1==0) event.value = "";
else event.value = v1-0.75

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
Explorer ,
Aug 08, 2024 Aug 08, 2024

Copy link to clipboard

Copied

thank you, this works. 
I still seem to be having issues though.

I have textfield Text 3 which has this code:

var v1 = Number(this.getField("Text2").value);
var v2 = Number(this.getField("Text1").value);
if (v1==0) event.value = "";
else event.value = v2-v1

This works fine.

And I have text field Text6

Which has this code:
var v5 = Number(this.getField("Text3").value);
if (v5==0) event.value = "";
else event.value = v5-0.25

Which works once. after that it keeps showing the wrong number.

If I remove the number from text2, it does show nothing, but if I enter a number again it only show -0,25

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 ,
Aug 08, 2024 Aug 08, 2024

Copy link to clipboard

Copied

Change the field calculation order.

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
Explorer ,
Aug 09, 2024 Aug 09, 2024

Copy link to clipboard

Copied

I'm sorry, I am a noob. I don't understand what exactly I should change

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 ,
Aug 09, 2024 Aug 09, 2024

Copy link to clipboard

Copied

You can change it at:

Bild1.jpg

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
Explorer ,
Aug 09, 2024 Aug 09, 2024

Copy link to clipboard

Copied

LATEST

perfect. I have never noticed that before. thank you

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