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

Javascript for Radio buttons used to calculate field value

Community Beginner ,
May 04, 2021 May 04, 2021

I have 2 groups of radio buttons

Group 1 is named "FTO" and has options "FIRSTTIME" and "REORDER"

Group 2 is named "DST" and has options "YES" and "NO"

 

What Javascript do I use to get the value of the radio buttons and use them in a calculated field?

My end goal is to say "if REORDER is checked, then event.value=0 else if DST is set to "YES", then event.value=100 else event.value=75.

 

I'm a total newbie at Javascript, so any help is appreciated.  This is what I tried last:

var radioFTO = this.getField("FTO").value
var radioDST = this.getfield("DST").value
if (radioFTO.value="REORDER") {event.value=0}
else if (radioDST.value="YES") {event.value=100}
else {event.value=75}

TOPICS
How to , JavaScript
772
Translate
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 Expert ,
May 04, 2021 May 04, 2021

Hi,

 

I think you are just using the value() call to often, and you also need to use two equals signs for "is equal to" something like

 

var radioFTO = this.getField("FTO").value
var radioDST = this.getfield("DST").value
if (radioFTO=="REORDER") {event.value=0}
else if (radioDST=="YES") {event.value=100}
else {event.value=75}

Translate
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 Expert ,
May 04, 2021 May 04, 2021
LATEST

Small correction. The second line should be:

var radioDST = this.getField("DST").value;

Translate
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