Skip to main content
Participant
November 11, 2023
Answered

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

  • November 11, 2023
  • 1 reply
  • 1918 views

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.

This topic has been closed for replies.
Correct answer Nesa Nurani

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;

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
November 12, 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;

Participant
December 5, 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".  

 

Nesa Nurani
Community Expert
Community Expert
December 5, 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.


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?