Skip to main content
Inspiring
Dec 20, 2018 4:55 PM UTC
Question

Custom calculation script

Novice Alert

I've got a field where I'm trying to provide some feedback text based on the answers in other fields, it's only partially working though.  The custom calculation script is:

if(this.getField("Box 1").value == "Off") event.value = "";

if(this.getField("Box1").value == "Yes") event.value = "";

if(this.getField("Box 1").value == "No") event.value = "Feedback text 1.";

if(this.getField("Box 2").value == "Don't Know")event.value= "";

if(this.getField("Box 2").value == "Off") event.value = ""; 

if(this.getField("Box 2").value == "Yes") event.value = "";

if(this.getField("Box 2").value == "No") event.value = "Feedback text 2.";

if(this.getField("NonPassCarryingLiftsQuarterlyInspections").value == "Don't Know")event.value= "";

However, the field only displays Feedback text 1 and not feedback text 2

What am I doing wrong?

TIA

This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

try67
Community Expert
Community Expert
Dec 20, 2018 5:54 PM UTC

You need to clearly define the rules of how it should work, then write the code to implement those rules.

The way you have it now the value of Box 1 (which you misspelled in the second code line, by the way) is not likely to matter at all, because the conditions regarding Box 2 and "NonPassCarryingLiftsQuarterlyInspections" will overwrite any values that were assigned previously.

Translate
EllenBCCAuthor
Inspiring
Dec 21, 2018 8:23 AM UTC

Thanks George.

How do I define the rules?  I'm not great with JavaScript.. just trying to build a form for a colleague.

Translate
Inspiring
Dec 20, 2018 5:02 PM UTC

Check the JavaScript console for errors, and check that the field calculation order makes sense for how the form is set up. Note that the field calculation order is not the same thing as the tab order.

Translate