Skip to main content
Inspiring
December 20, 2018
Question

Custom calculation script

  • December 20, 2018
  • 2 replies
  • 629 views

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 has been closed for replies.

2 replies

try67
Community Expert
Community Expert
December 20, 2018

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.

EllenBCCAuthor
Inspiring
December 21, 2018

Thanks George.

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

Inspiring
December 20, 2018

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.