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

Radio button if then statement

New Here ,
Feb 13, 2022 Feb 13, 2022

Hi,

I am creating a PDF form that consists a questionnaire to fill out by the participants.

My questionnaire consists of 4 parameter: Always, Mostly Yes, Hardly Ever, Never

I am trying to assign a value for when one radio button or another is clicked.

 

I Would like to create a statement which says that if the radio button for Always or Mostly Yes is checked, then the value will be 1 (value will be seen in a different table) , or esle, the value will be none (""). 

 

Since I want the radio buttons, the name must be the same which then makes it difficult for me to relate to the export values of each radio button.

Sorry I am new to javascript and writing codes.. would really appriciate the assitance. 

Thank you!

 

TOPICS
JavaScript , PDF forms
1.2K
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 ,
Feb 13, 2022 Feb 13, 2022
LATEST

So let's say you have a radio-button group called "Q1" with these four texts as the export values of each field in the group. As the custom calculation script of the text field where you want to show the result enter the following code:

 

var v = this.getField("Q1").valueAsString;

event.value = (v=="Always" || v=="Mostly Yes") ? 1 : "";

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