Skip to main content
Inspiring
Mar 11, 2025 9:02 PM UTC
Question

Coding for Right or LEft

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
}

13 replies

Nesa Nurani
Community Expert
Community Expert
Mar 12, 2025 5:14 AM UTC

Where did you put the script?

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

Translate
Inspiring
Mar 12, 2025 3:15 PM UTC

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. 

Translate
Nesa Nurani
Community Expert
Community Expert
Mar 12, 2025 3:28 PM UTC

Is your field named "Text23" or "Field23"?

Check that your field name is correct, also you can check console (CTRL+J) for any errors.

Translate