Skip to main content
Participant
January 9, 2024
解決済み

Custom script to auto populate a text field with the negative number of a different text field

  • January 9, 2024
  • 返信数 1.
  • 839 ビュー

I am trying to figure out a way to auto populate a text field with the negative number of a different text field. For example if the user enters 20 in one text field, a text field in another section will auto populate with -20. 

 

Can this be done? 

 

Thank you for your help!

このトピックへの返信は締め切られました。
解決に役立った回答 Nesa Nurani

Let's say the field where you want to show negative number is named "Text2" as 'Validate' script of field where you enter value use this:

var t2 = this.getField("Text2");
if(event.value && !isNaN(event.value))
 t2.value = -parseFloat(event.value);
else
 t2.value = "";

返信数 1

Nesa Nurani
Community Expert
Nesa NuraniCommunity Expert解決!
Community Expert
January 9, 2024

Let's say the field where you want to show negative number is named "Text2" as 'Validate' script of field where you enter value use this:

var t2 = this.getField("Text2");
if(event.value && !isNaN(event.value))
 t2.value = -parseFloat(event.value);
else
 t2.value = "";
Participant
January 9, 2024

Thank you so much for responding so quickly! This worked perfectly.