• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Multiple choice calculated field

Community Beginner ,
Jan 20, 2021 Jan 20, 2021

Copy link to clipboard

Copied

I have one other type of field I am trying to make work, but it comes from a possibility of 4 different answers.

 

If they select one trait they get one result, another gets a different result and no trait gets no result. I can't remember how to do an array and I seemed to remember you could nest ifs. This is what I came up with:

 

var IntMod = Number(this.getField("IntMod").value);

var WisMod = Number(this.getField("WisMod").value);

var ChaMod = Number(this.getField("ChaMod").value);


if(this.getField("Ability").value != "Wisdom"){
event.value = WisMod + 10;}

Else

if(this.getField("Ability").value != "Charisma"){
event.value = ChaMod + 10;}
else

if(this.getField("Ability").value != "Intelligence"){
event.value = IntMod + 10;}
else
event.value = 0;

 

Thank you for your help. It has been a while.

 

Regards,

 

Larry

TOPICS
PDF forms

Views

399

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 21, 2021 Jan 21, 2021

Hi, javascript is case sensitive so in your code first 'Else' should be 'else'.

If you try add +10 to 'WisMod' field if value is 'Wisdom' then you need to use '==' not '!=',

'!=' that means value is not 'Wisdom', and '==' means value is 'Wisdom'.

Hope thats what you looking for 🙂

Votes

Translate

Translate
Community Expert ,
Jan 21, 2021 Jan 21, 2021

Copy link to clipboard

Copied

Hi, javascript is case sensitive so in your code first 'Else' should be 'else'.

If you try add +10 to 'WisMod' field if value is 'Wisdom' then you need to use '==' not '!=',

'!=' that means value is not 'Wisdom', and '==' means value is 'Wisdom'.

Hope thats what you looking for 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 21, 2021 Jan 21, 2021

Copy link to clipboard

Copied

LATEST

Thanks again for all your help. Like I said been a while since I used javascript here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines