Skip to main content
Participating Frequently
February 11, 2017
Answered

checkbox javascript calculation not auto updating

  • February 11, 2017
  • 1 reply
  • 779 views

i have a costume calculation set to a checkbox  and if i  change one of the fields it pulls the data from i have to uncheck and recheck the box for it to reflect the change.

any way to create a refresh script and set it to a button or in the text filed so if it's changed it will refresh the script

script is set on the button, as on mouse up run script

script does this

if box = yes

add Field A + B + 8

print in filed C

if box = no

add Field A + B

print in filed C

This topic has been closed for replies.
Correct answer try67

No it's on the check box


You should move it to be the custom calculation script of the text field.

Use this code:

var x = Number(this.getField("Text1").value);

var y = Number(this.getField("Modifier").value);

if (this.getField("Checkbox2").valueAsString == "Yes") {

  event.value = x+y;

} else {

    event.value = y;

}

1 reply

try67
Community Expert
Community Expert
February 11, 2017

Can you post your actual code?

Participating Frequently
February 11, 2017

   // JavaScript Document

    var x = this.getField("Text1").value;

    var y = this.getField("Modifier").value;

    if (this.getField("Checkbox2").value == "Yes")

{

       this.getField("total").value = x+y;

}

       else

{

        this.getField("total").value = y;

}

try67
Community Expert
Community Expert
February 11, 2017

Is this the calculation code for the "total" field?