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

How can I have a radio button selection grey out a drop menu option.

Community Beginner ,
Nov 11, 2023 Nov 11, 2023

I have a form that one of the questions is Male or Female and a Radio button for each choice, after selecting Female I want a drop down menu that asks if Pregnant.  So I have put a drop down next to it with a Yes or No to select.  Obviously if you select male I want the drop down to be grey out or not able to select it.  Thank you in advanced for the help.

TOPICS
Create PDFs
1.4K
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
1 ACCEPTED SOLUTION
Community Expert ,
Nov 11, 2023 Nov 11, 2023

Let's say your choices in radio buttons are named "Male" and "Female" and your dropdown field is named "Pregnant,
use this as 'Mouse Up' action (Run a JavaScript) of "Male" radio button:
if(event.target.value == "Male")
this.getField("Pregnant").readonly = true;

 

use this as 'Mouse Up' action (Run a JavaScript) of "Female" radio button:
if(event.target.value == "Female")
this.getField("Pregnant").readonly = false;

View solution in original post

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 ,
Nov 11, 2023 Nov 11, 2023

Let's say your choices in radio buttons are named "Male" and "Female" and your dropdown field is named "Pregnant,
use this as 'Mouse Up' action (Run a JavaScript) of "Male" radio button:
if(event.target.value == "Male")
this.getField("Pregnant").readonly = true;

 

use this as 'Mouse Up' action (Run a JavaScript) of "Female" radio button:
if(event.target.value == "Female")
this.getField("Pregnant").readonly = false;

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 ,
Nov 12, 2023 Nov 12, 2023

It might also be a good idea to reset the "Pregnant" field when "Male" is selected, just in case.

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 Beginner ,
Dec 05, 2023 Dec 05, 2023

Thank you for your answer, however it gives me an error.  Im not sure if this makes a diference but the Male Femal Radio buttons and Pregnant drop down menu are part of a radio group called "Aplicant Gender".  

 

Screenshot 2023-12-05 at 10.46.39 AM.png

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 ,
Dec 05, 2023 Dec 05, 2023

What is the error you get?

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 Beginner ,
Dec 05, 2023 Dec 05, 2023

Actullay I did a mistake it works, however if I select Female and also select yes or no, then l go back and select Male "Yes" or "No" is still displayed.Screenshot 2023-12-05 at 11.52.22 AM.png

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 ,
Dec 05, 2023 Dec 05, 2023

What should be displayed? You said you only have "Yes" and "No" in dropdown, do you have a default value like empty space or something else?

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 Beginner ,
Dec 05, 2023 Dec 05, 2023
LATEST

I got it, there is a blank space option and I just realised that the mouse up can have 2 functions and one of them I set up is to reset the form but I de selected all and just maid it to reset "Pregnant", thanks alot!!

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