Copy link to clipboard
Copied
Im building a spreadsheet for a gaming character sheet and Im having trouble implementing a javascript to do an "if-then command.
I have a pulldown list and I need a text field box to refer to which selection was made and then implement one math problem (adding up separate fields) or another.
For example under Race Pulldown there is Human or Halfling. If they pick Human then text field box needs to show the total calculation result of text field A+B. If it shows Halfling then it needs to show the result of text field A+C.
I tried using:
if (this.getField("Race Pulldown").value == "Halfling"){
event.target.display = display.visible;
}
else{
event.target.display = display.hidden;
}
and replacing event.targeting.display with the math calculation but I couldnt get it to work
Thanks
Chad
Try this code:
if (this.getField("Race Pulldown").value == "Halfling"){
event.value = Number(this.getField("A").valueAsString) + Number(this.getField("C").valueAsString);
} else {
event.value = Number(this.getField("A").valueAsString) + Number(this.getField("B").valueAsString);
}
Copy link to clipboard
Copied
Try this code:
if (this.getField("Race Pulldown").value == "Halfling"){
event.value = Number(this.getField("A").valueAsString) + Number(this.getField("C").valueAsString);
} else {
event.value = Number(this.getField("A").valueAsString) + Number(this.getField("B").valueAsString);
}