Skip to main content
Inspiring
March 11, 2025
Question

Coding for Right or LEft

  • March 11, 2025
  • 1 reply
  • 1453 views

I have a form where I want an answer in lateralside1 but the decision of what types into this field is from text 23. IF Text23 is <0 I want Right in Lateralside 1 and if >0 then I want the word Left. I tried this script but it didn't work.  Any one know what I am missing? Thank you in advance.

 

var number = this.getField("Text23").value; // Get the value from Text23
if (number > 0) {
event.value = "Left"; // If the number is greater than 0, display "Left"
} else if (number < 0) {
event.value = "Right"; // If the number is less than 0, display "Right"
} else {
event.value = ""; // If the number is exactly 0, leave the field empty
}

1 reply

Nesa Nurani
Community Expert
March 12, 2025

Where did you put the script?

It should go under 'Calculate' tab as custom calculation script of "Lateralside 1" field.

Inspiring
March 12, 2025

Hi Nesa, I have put the script there and it likes the code but it still is not displaying the word left or right in the fields. Right now Field23 has the number -.35 in it so it should display the word Right. 

Nesa Nurani
Community Expert
March 12, 2025

It is Text23.  I appreciate your help. This one has stumped me. 


Did you solve it or you need further help?