Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Display/Hide a textbox based on dropdown with scriptrunner

Arun_Mozhi February 13, 2020

I would like to write a script with Script runner that updates the text boxes based on drop-down values.

The drop down has three values  - default, X and Y. when the user selects default, no field should be displayed. When the user selects X, the text box corresponding to X should be displayed. Similarly when the user selects Y, the text box corresponding Y should be displayed.

The change should happen before the issue is created. Is there a way to select the fields dynamically..?

 

3 answers

1 accepted

1 vote
Answer accepted
Arun_Mozhi February 25, 2020

Finally got the solution by adding a behaviour on field level and added a server side script.

 

def CField1= getFieldByName("Field Name 1")
def CField2= getFieldByName("Field Name 2")

def TCType = getFieldById(getFieldChanged())
def selectedOption = TCType .getValue() as String


if(selectedOption=="Status")
{
CField1.setHidden(false)
CField2.setHidden(true)
}

else if (selectedOption=="Results")
{
CField1.setHidden(true)
CField2.setHidden(false)
}

else if (selectedOption==null)
{
CField1.setHidden(true)
CField2.setHidden(true)
}

0 votes
Kevin O'Shaughnessy June 27, 2022

Hi all

Anyone know how I can just get a script that will create a text box when I select "Other" from my dropdown list?

Really need help here?

0 votes
Andrew Morin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 13, 2020

Suggest an answer

Log in or Sign up to answer