One Custom Field show another custom field based on answer?

Bryan Trummer - ReleaseTEAM
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 12, 2013

I would like to have in my resolution screen a custom field with two radio buttons (yes,no). If yes is selected another free text field will appear, if no is selected nothing will happen. Is this something that can be done in JIRA 4.1? Any help is appreciated!

2 answers

0 votes
RambanamP
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.
September 12, 2013

add this script on free text field description in field configuration

<script type="text/javascript">
var radioButtonName = document.getElementsByName('customfield_10570');
var textFieldRow = document.getElementById('customfield_10571FieldArea');
var textField = document.getElementById('customfield_10571');
textFieldRow.style.display = 'none';
for(var x = 0; x < radioButtonName.length; x ++){
radioButtonName[x].onclick=function(){showHideField();}; 
}
function showHideField(){
var checkedId = "";
for (var x = 0; x < radioButtonName.length; x ++){
if(radioButtonName[x].checked == true)
checkedId = radioButtonName[x].value;
        }
if( checkedId == "Yes" ){ 
textFieldRow.style.display = '';
}else {
textField.value = '';
textFieldRow.style.display = 'none';
}
}
showHideField();
</script>

Note: change custom fields as per your instance

Bryan Trummer - ReleaseTEAM
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 12, 2013

Do I need to have this script in the radio button or the text field when yes is selected

Bryan Trummer - ReleaseTEAM
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 12, 2013

I do appreciate any and all help as I am fairly new to a lot of this.

So my radio button ID is 10172 and the free text field that I want to appear if the Yes radio button selected is 10173. I thought I plugged it in correctly but here is the code I have the in the radio button field description.

<script type="text/javascript">
var radioButtonName = document.getElementsByName('customfield_10172');
var textFieldRow = document.getElementById('customfield_10173FieldArea');
var textField = document.getElementById('customfield_10173');
textFieldRow.style.display = 'none';
for(var x = 0; x < radioButtonName.length; x ++){
radioButtonName[x].onclick=function(){showHideField();};
}
function showHideField(){
var checkedId = "";
for (var x = 0; x < radioButtonName.length; x ++){
if(radioButtonName[x].checked == true)
checkedId = radioButtonName[x].value;
}
if( checkedId == "Yes" ){
textFieldRow.style.display = '';
}else {
textField.value = '';
textFieldRow.style.display = 'none';
}
}
showHideField();
</script>
RambanamP
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.
September 16, 2013

you have to textarea field description(which is last in the form)

don't forgot to add in field description of fieldconfiguration

0 votes
Timothy
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.
September 12, 2013

You might want to add a Javascript into custom field or the field configuration to manipulate the DOM. Google around, there are examples.

Suggest an answer

Log in or Sign up to answer