Skip to main content
Participant
January 18, 2023
Question

Need button to have 2 actions

  • January 18, 2023
  • 1 reply
  • 494 views

Hey.

I need a button for my D&D charactersheet to have 2 actions.
The actions would be to add several boxes for a total in a final box, or only a base number put in ther final box. It's about having the proficiency bonus box added to the base stat modifier box, with the total placed into a 3rd box.

Example
Checked : Box 1 + Box 2 = Box 3
Unchecked : Box 1 = Box 3

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
January 18, 2023

Use this as custom calculation script of "Box 3" and change 'Button'  to your actual radio button name.

var b1 = this.getField("Box 1");
var b2 = this.getField("Box 2");
var check = this.getField("Button").valueAsString;
if(check == "Off")
event.value = b1.value;
else
event.value = Number(b1.value)+Number(b2.value);

 

Participant
January 18, 2023

Sorry

I meant to say the checkbox, not button.

Nesa Nurani
Community Expert
Community Expert
January 18, 2023

You also want to show plus sign?

Try this:

var str = this.getField("STR");
var dex = this.getField("DEX");
var check = this.getField("Check Box1").valueAsString;
if(str.valueAsString == "")
event.value = "";
else if(check == "Off")
event.value = "+"+str.value;
else
event.value = "+"+(Number(str.value)+Number(dex.value));